<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>
我收到此错误,内容为
"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Query String' at line 1"
我该如何解决这个问题?非常感谢!
最佳答案
您尝试执行以下查询:
Query String
你需要这样做:
if ($q1 = mysqli_query($conn,"select * from joseph.inpatient_1501003f"))
而不是:
$q1 = mysqli_query($conn," select * from joseph.inpatient_1501003f");
if ($q1 = mysqli_query($conn,"Query String")){...}
关于php - mySQL 语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35271954/