doukengsha9472 2014-12-29 18:42
浏览 22

Google SQL PHP没有数据显示 - 已连接

I am struggling to view some data via PHP. I have a SQL database with Google. I am struggling to extract the data and desperately need some help!

The PHP keeps saying there is 0 records, even though there is a number of records within the 'timing' database and 'events' table.

If anyone has any ideas why this is not working I would be very grateful!

<?php
$link = new mysqli('IP_ADDRESS:3306','root','PASSWORD',timing);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully ';
$sql = "SELECT event_id FROM events";
$result = $link->query($sql);
if ($result->num_rows > 0) {
echo "<table><tr><th>Event ID</th><th>Event Name</th></tr>";
// output data of each row
while($row = $result->fetch_assoc()) {
echo "id: " . $row["event_id"];
}
echo "</table>";
}
else {
echo "0 results";
}
mysql_close($link);
?> 
  • 写回答

2条回答 默认 最新

  • dsds33222 2014-12-29 19:11
    关注

    Unless timing is a defined constant, and it looks like that is not the case, being that a string you should wrap it in quotes or double-quotes. A non-defined constant should cast to a string in any case, but since i can't see any other error in your code that might be what is causing your issue. Try changing

    $link = new mysqli('IP_ADDRESS:3306','root','PASSWORD',timing);
    

    to

    $link = new mysqli('IP_ADDRESS:3306', 'root', 'PASSWORD', 'timing');
    
    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)