Tôi đang cố gắng chạy phần sau.mysqli đưa ra "Lệnh không đồng bộ" - tại sao?
<?php
$db = mysqli_connect("localhost","user","pw") or die("Database error");
mysqli_select_db($db, "database");
$agtid = $_POST['level'];
$sql = sprintf("call agent_hier(%d)", $agtid);
$result = mysqli_query($db, $sql) or exit(mysqli_error($db));
if ($result) {
echo "<table border='1'>
<tr><th>id</th>
<th>name</th>
<th>parent_id</th>
<th>parent_name</th>
<th>level</th>
<th>email</th></tr>";
while ($row = mysqli_fetch_assoc($result))
{
$aid = $row["id"];
$sql2 = "SELECT * FROM members WHERE MEMNO = '$aid'";
$result2 = mysqli_query($db,$sql2) or exit(mysqli_error($db));
while ($newArray = mysqli_fetch_array($result2)) {
$fname = $newArray['FNAME'];
$lname = $newArray['LNAME'];
$mi = $newArray['MI'];
$address = $newArray['ADDRESS'];
$city = $newArray['CITY'];
$state = $newArray['STATE'];
$zip = $newArray['ZIP'];
$kdate = $newArray['KDATE'];
$date = abs(strtotime(date('m/d/Y')) - strtotime(date($kdate)))/(60 * 60 * 24);
}
echo sprintf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>",
$row["id"],$row["name"],
$row["parent_id"],$row["parent_name"],
$row["level"],$row["email"]);
}
echo "</table>";
}
mysqli_free_result($result);
mysqli_close($db);
?>
Nếu tôi loại bỏ các nếp:
$aid = $row["agent_id"];
để ....
$date = abs(strtotime(date('m/d/Y')) - strtotime(date($kdate)))/(60 * 60 * 24);
}
mọi thứ sẽ hoạt động tốt. Nếu không, tôi nhận được lỗi sau:
Commands out of sync; you can't run this command now
Trong nghiên cứu, tôi nghĩ rằng nó có thể là do nhiều truy vấn MySQLi chạy cùng một lúc, trong đó sử dụng mysqli_multi_query
nhưng đối với tất cả các mẫu và các dữ liệu chung trong the guide làm dường như không được áp dụng.
Bất kỳ ý tưởng nào?
đâu là dòng '$ date = abs (strtotime (ngày ('m/d/Y')) - strtotime (ngày ($ kdate)))/(60 * 60 * 24); } 'trong mã của bạn? Bạn nói nếu bạn loại bỏ nó, nhưng tôi không thể nhìn thấy nó ở đó. – avacariu
@vlad - lời xin lỗi của tôi, cố định – JM4