【发布时间】:2013-11-16 06:40:02
【问题描述】:
我正在使用以下 PHP 代码从服务器中的数据库中检索“位置”字段,但是当我运行 PHP 时出现如下所示的错误。
我的 PHP 文件:
<?php
$con=mysqli_connect("localhost","naveen","naveen123","naveen_z");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT 'Location' FROM `map_details` ");
print_r($result);
mysqli_close($con);
?>
我的数据库结构:
我收到以下错误:
Parse error: syntax error, unexpected $end in location.php on line 12
现在,我收到了:
{"current_field":null,"field_count":null,"lengths":null,"num_rows":null,"type":null} –
【问题讨论】:
-
观察:不要混合和匹配标识符引号。始终使用
`(或者,更好的是,仅在需要时引用)。'不应该用于标识符,因为它实际上是一个 ANSI SQL 字符串引号 :( -
你能以正确的格式制作那个 php,因为现在它正在将所有值显示为 null {"current_field":null,"field_count":null,"lengths":null,"num_rows ":null,"type":null} –
-
$result 指的是 整个 结果,而不是特定的行。它说“没有行”(
"num_rows":null)所以 map_details 表很可能是空的。无论如何,这是一个不同(且不相关)的问题 - 根据需要发布一个 new 问题(但首先验证或反驳我之前的断言)。 -
不检查这张桌子的图片tinypic.com/r/2vxjfps/5
标签: php html sql database select