【发布时间】:2016-02-08 22:29:02
【问题描述】:
<html>
<head><title> InpatientList </title><head>
<body>
<h1> InpatientList </h1>
<?php
$conn = mysqli_connect("127.0.0.1","root","root","");
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$q1 = mysqli_query($conn," select * from joseph.inpatient_1501003f");
if ($q1 = mysqli_query($conn,"Query String")) {
while ($r1 = mysqli_fetch_row($q1)) {
for ($k=0; $k<count($r1); $k++){
print htmlspecialchars($r1[$k]). " : ";
}
print "<BR>";
};
} else {
printf("Errormessage: %s\n", mysqli_error($conn));
}
mysqli_close($conn);
?>
</body>
</html>
我收到了这个错误,上面写着
“您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“查询字符串”附近使用正确的语法”
我该如何解决这个问题?非常感谢!
【问题讨论】:
-
你的声明
if ($q1 = mysqli_query($conn,"Query String")) {没有意义 -
那是什么?
mysqli_query($conn,"Query String") -
if ($q1 = mysqli_query($conn,"Query String")) {无用并产生错误。删除它 -
哈哈,错过了!对不起!
-
@josephkoh 感谢您的标记。你也可以投票。 :)