<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>
I got this error which says
"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"
How do i fix this? Appreciated much!
You try to execute the following query :
Query String
You need to do this :
if ($q1 = mysqli_query($conn,"select * from joseph.inpatient_1501003f"))
Instead of :
$q1 = mysqli_query($conn," select * from joseph.inpatient_1501003f");
if ($q1 = mysqli_query($conn,"Query String")){...}
You are performing two queries in which first one is correct but te second one in if
condition is totally wrong.
So remove if ($q1 = mysqli_query($conn,"Query String")) {
condition and rest will be ok.
Note:- remove this condition and its ending }
also.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.