gpt4 book ai didi

javascript - 第 6 行 mysql_fetch_array 错误

转载 作者:行者123 更新时间:2023-11-28 05:54:32 25 4
gpt4 key购买 nike

mysql_fetch_array() expects parameter 1 to be resource, boolean given in

<?php
mysql_connect ("localhost", "cab","a321") or die (mysql_error());
mysql_select_db ("ppwxpjey_mcidb");
$termOrd = $_POST['termOrd'];
$sql = mysql_query("select * from booking where order_no like '%$termOrd%'");
while ($row = mysql_fetch_array($sql)){
echo "<table width='1000' border='2' align='center' style='background-color:#FFFFFF;border-collapse:collapse;border:2px solid #6699FF;color:#000000'><tr><th>ORDER NO</th><th>NAME</th><th>MOBILE</th><th>FROM PLACE</th><th>TO PLACE</th><th>JOURNEY DATE</th><th>JOURNEY TIME</th><th>PERSON</th><th>BOOKING TIME</th></tr>";
echo "<tr><td>".$row["ORDER_NO"]."</td><td>".$row["NAME"]."</td><td>".$row["MOBILE"]."</td><td>".$row["FROM_PLACE"]."</td><td>".$row["TO_PLACE"]."</td><td>".$row["JOURNEY_DATE"]."</td><td>".$row["JOURNEY_TIME"]."</td><td>".$row["PERSON"]."</td><td>".$row["UPDATE_TIME"]."</td></tr>";
echo '<br/>';
}
?>

最佳答案

您必须在将查询传入 mysql_fetch_array 之前运行该查询它期望资源作为参数。所以像这样改变你的代码,

$sql = mysql_query("select * from booking where order_no like '%$termOrd%'");

$result = mysql_query($query) or die(mysql_error());
// This is where you're getting resource or throwing SQL error.

while ($row = mysql_fetch_array($result)){
// YOUR LOGIC.
}

Warning mysql_query, mysql_fetch_array,mysql_connect etc.. extensions were deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0.
Instead, the MySQLi or PDO_MySQL extension should be used.
Source : http://php.net/manual/en/function.mysql-query.php

因此请尽快更新您的代码。

关于javascript - 第 6 行 mysql_fetch_array 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37810757/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com