为什么mysqli给出“命令不同步”错误?
我正在尝试运行以下内容。
<?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);?>
如果我删除以下行:
$aid = $row["agent_id"];
至....
$date = abs(strtotime(date('m/d/Y')) - strtotime(date($kdate))) / (60 * 60 * 24); }
一切都会好起来的。如果没有,我收到以下错误:
命令不同步; 你现在不能运行这个命令
在研究,我认为这可能是由于在同一时间运行多个MySQLi的查询,其中使用mysqli_multi_query
,但所有样品和一般数据的引导似乎并不适用。
有任何想法吗?
慕妹3146593
繁花如伊
倚天杖