mysql_fetch_array()期望参数1是资源错误[重复](mysql_fetch_array() expects parameter 1 to be resource error [duplicate])
这是我得到的错误:警告:mysql_fetch_array()期望参数1是资源,布尔值在.....中给出
我试图找出错误,但我无法做到......有人可以帮我看看吗?
<?php session_start(); $objConnect = mysql_connect("localhost","root","") or die(mysql_error()); $objDB = mysql_select_db("EMC"); $haha = $fgmembersite->UserEmail(); $_SESSION['storedemail']= $haha; $query = mysql_query("SELECT * FROM Register WHERE Email= '$haha'"); while ($row = mysql_fetch_array($query)){ $id = $row['ID']; } mysql_free_result($query); $txtFirstName = isset($_GET['txtFirstName']) ? $_GET['txtFirstName'] : ""; $txtLastName = isset($_GET['txtLastName']) ? $_GET['txtLastName'] : ""; $txtCell = isset($_GET['txtCell']) ? $_GET['txtCell'] : ""; ?> <html> <body> <form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table width="599" border="1"> <tr> <th>Keyword</th> <input name="txtFirstName" type="text" id="txtFirstName" value='<?php echo htmlentities($txtFirstName) ?>'> <input name="txtLastName" type="text" id="txtLastName" value='<?php echo htmlentities($txtLastName) ?>'> <input name="txtCell" type="text" id="txtCell" value='<?php echo htmlentities($txtCell) ?>'> <? $opselect="SELECT DISTINCT Custgroup FROM UserAddedRecord"; $result = mysql_query ($opselect); while($nt=mysql_fetch_array($result)) { ?> <option><?= $nt[Custgroup]?></option>"; <? } ?> </select> <input type="submit" value="Search"> </tr> </table> </form> <? if (isset($_GET["txtFirstName"]) != "" || isset($_GET["txtLastName"]) != "" || isset($_GET["txtCell"]) != "" || isset($_GET["txtGroup"]) != "") { $objConnect = mysql_connect("localhost","root","") or die(mysql_error()); $objDB = mysql_select_db("EMC"); // Search By Name or Email $strSQL = "SELECT * FROM UserAddedRecord WHERE (FirstName LIKE '%".$_GET["txtFirstName"]."%' and LastName LIKE '%".$_GET["txtLastName"]."%' and Cell LIKE '%".$_GET["txtCell"]."%' and Custgroup LIKE '%".$_GET["txtGroup"]."%')"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 2; // Per Page if(!isset($_GET['Page'])) { $Page = 1; } else { $Page = $_GET['Page']; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by addedrec_ID DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <table width="600" border="1"> <tr> <th width="50"> <div align="center">#</div></th> <th width="91"> <div align="center">CustomerID </div></th> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Email </div></th> <th width="97"> <div align="center">MobileCompany </div></th> <th width="59"> <div align="center">Cell </div></th> <th width="71"> <div align="center">WorkPhone </div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?=$objResult["addedrec_ID"];?>"></div></td> <td><div align="center"><?=$objResult["addedrec_ID"];?></div></td> <td><?=$objResult["FirstName"];?></td> <td><?=$objResult["LastName"];?></td> <td><div align="center"><?=$objResult["MobileCompany"];?></div></td> <td align="right"><?=$objResult["Cell"];?></td> <td align="right"><?=$objResult["Workphone"];?></td> </tr> <? } ?> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { if($_GET["txtFirstName"] == "") { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtLastName=$_GET[txtLastName]'><< Back</a> "; } else { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtFirstName=$_GET[txtFirstName]'><< Back</a> "; } } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtFirstName=$_GET[txtFirstName]'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "" && $_GET["txtCell"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtGroup=$_GET[txtGroup]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtCell=$_GET[txtCell]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" ) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtLastName=$_GET[txtLastName]'>Next>></a> "; } else { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtFirstName=$_GET[txtFirstName]'>Next>></a> "; } } mysql_close($objConnect); } else { $strSQL = "SELECT * FROM UserAddedRecord WHERE user_id='$id'"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 2; // Per Page if(!isset($_GET['Page'])) { $Page = 1; } else { $Page = $_GET['Page']; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by id DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <table width="600" border="1"> <tr> <th width="50"> <div align="center">#</div></th> <th width="91"> <div align="center">ID </div></th> <th width="198"> <div align="center">First Name </div></th> <th width="198"> <div align="center">Last Name </div></th> <th width="250"> <div align="center">Mobile Company </div></th> <th width="100"> <div align="center">Cell </div></th> <th width="100"> <div align="center">Workphone </div></th> <th width="100"> <div align="center">Group </div></th> </tr> <? echo "<form name='form1' method='post' action=''>"; while($objResult = mysql_fetch_array($objQuery)) { echo "<tr>"; echo "<td align='center'><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$objResult[addedrec_ID]\"></td>"; echo "<td>$objResult[addedrec_ID] </td>"; echo "<td>$objResult[FirstName]</td>"; echo "<td>$objResult[LastName] </td>"; echo "<td>$objResult[MobileCompany] </td>"; echo "<td>$objResult[Cell] </td>"; echo "<td>$objResult[WorkPhone] </td>"; echo "<td>$objResult[Custgroup] </td>"; echo "</tr>"; } echo "<td colspan='7' align='center'><input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\">"; if(isset($_POST['delete'])) // from button name="delete" { $checkbox = $_POST['checkbox']; //from name="checkbox[]" $countCheck = count($_POST['checkbox']); for($d=0;$d<$countCheck;$d++) { $del_id = $checkbox[$d]; $sql = "DELETE from UserAddedRecord where addedrec_ID = $del_id"; $result2=mysql_query($sql); } if($result2) { header('Location: customer-adddata.php'); } else { echo "Error: ".mysql_error(); } } echo "</form>"; ?> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { if($_GET["txtFirstName"] == "") { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtLastName=$_GET[txtLastName]'><< Back</a> "; } else { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtFirstName=$_GET[txtFirstName]'><< Back</a> "; } } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtFirstName=$_GET[txtFirstName]'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtCell=$_GET[txtCell]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" ) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtLastName=$_GET[txtLastName]'>Next>></a> "; } else { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtFirstName=$_GET[txtFirstName]'>Next>></a> "; } } mysql_close($objConnect); } ?> </body> </html>
提前致谢。
问题解决了。
谢谢大家回答我的问题,这是我的错误:
注意:'order clause'中的未知列'id'在......
我忘记在这里改变我的身份:
$strSQL .=" order by id DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL) or trigger_error(mysql_error());;
它应该是:
$strSQL .=" order by addedrec_ID DESC LIMIT $Page_Start , $Per_Page";
请允许我再次表示感谢,并祝大家度过美好的一天。
Possible Duplicate:
mysql_fetch_array() expects parameter 1 to be resource, boolean given in selectThis is the error I get: Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in.....
I tried to find out the error , but I can't make it...can someone please help me take a look?
<?php session_start(); $objConnect = mysql_connect("localhost","root","") or die(mysql_error()); $objDB = mysql_select_db("EMC"); $haha = $fgmembersite->UserEmail(); $_SESSION['storedemail']= $haha; $query = mysql_query("SELECT * FROM Register WHERE Email= '$haha'"); while ($row = mysql_fetch_array($query)){ $id = $row['ID']; } mysql_free_result($query); $txtFirstName = isset($_GET['txtFirstName']) ? $_GET['txtFirstName'] : ""; $txtLastName = isset($_GET['txtLastName']) ? $_GET['txtLastName'] : ""; $txtCell = isset($_GET['txtCell']) ? $_GET['txtCell'] : ""; ?> <html> <body> <form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>"> <table width="599" border="1"> <tr> <th>Keyword</th> <input name="txtFirstName" type="text" id="txtFirstName" value='<?php echo htmlentities($txtFirstName) ?>'> <input name="txtLastName" type="text" id="txtLastName" value='<?php echo htmlentities($txtLastName) ?>'> <input name="txtCell" type="text" id="txtCell" value='<?php echo htmlentities($txtCell) ?>'> <? $opselect="SELECT DISTINCT Custgroup FROM UserAddedRecord"; $result = mysql_query ($opselect); while($nt=mysql_fetch_array($result)) { ?> <option><?= $nt[Custgroup]?></option>"; <? } ?> </select> <input type="submit" value="Search"> </tr> </table> </form> <? if (isset($_GET["txtFirstName"]) != "" || isset($_GET["txtLastName"]) != "" || isset($_GET["txtCell"]) != "" || isset($_GET["txtGroup"]) != "") { $objConnect = mysql_connect("localhost","root","") or die(mysql_error()); $objDB = mysql_select_db("EMC"); // Search By Name or Email $strSQL = "SELECT * FROM UserAddedRecord WHERE (FirstName LIKE '%".$_GET["txtFirstName"]."%' and LastName LIKE '%".$_GET["txtLastName"]."%' and Cell LIKE '%".$_GET["txtCell"]."%' and Custgroup LIKE '%".$_GET["txtGroup"]."%')"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 2; // Per Page if(!isset($_GET['Page'])) { $Page = 1; } else { $Page = $_GET['Page']; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by addedrec_ID DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <table width="600" border="1"> <tr> <th width="50"> <div align="center">#</div></th> <th width="91"> <div align="center">CustomerID </div></th> <th width="98"> <div align="center">Name </div></th> <th width="198"> <div align="center">Email </div></th> <th width="97"> <div align="center">MobileCompany </div></th> <th width="59"> <div align="center">Cell </div></th> <th width="71"> <div align="center">WorkPhone </div></th> </tr> <? while($objResult = mysql_fetch_array($objQuery)) { ?> <tr> <td><div align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<?=$objResult["addedrec_ID"];?>"></div></td> <td><div align="center"><?=$objResult["addedrec_ID"];?></div></td> <td><?=$objResult["FirstName"];?></td> <td><?=$objResult["LastName"];?></td> <td><div align="center"><?=$objResult["MobileCompany"];?></div></td> <td align="right"><?=$objResult["Cell"];?></td> <td align="right"><?=$objResult["Workphone"];?></td> </tr> <? } ?> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { if($_GET["txtFirstName"] == "") { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtLastName=$_GET[txtLastName]'><< Back</a> "; } else { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtFirstName=$_GET[txtFirstName]'><< Back</a> "; } } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtFirstName=$_GET[txtFirstName]'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "" && $_GET["txtCell"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtGroup=$_GET[txtGroup]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtCell=$_GET[txtCell]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" ) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtLastName=$_GET[txtLastName]'>Next>></a> "; } else { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtFirstName=$_GET[txtFirstName]'>Next>></a> "; } } mysql_close($objConnect); } else { $strSQL = "SELECT * FROM UserAddedRecord WHERE user_id='$id'"; $objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]"); $Num_Rows = mysql_num_rows($objQuery); $Per_Page = 2; // Per Page if(!isset($_GET['Page'])) { $Page = 1; } else { $Page = $_GET['Page']; } $Prev_Page = $Page-1; $Next_Page = $Page+1; $Page_Start = (($Per_Page*$Page)-$Per_Page); if($Num_Rows<=$Per_Page) { $Num_Pages =1; } else if(($Num_Rows % $Per_Page)==0) { $Num_Pages =($Num_Rows/$Per_Page) ; } else { $Num_Pages =($Num_Rows/$Per_Page)+1; $Num_Pages = (int)$Num_Pages; } $strSQL .=" order by id DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL); ?> <table width="600" border="1"> <tr> <th width="50"> <div align="center">#</div></th> <th width="91"> <div align="center">ID </div></th> <th width="198"> <div align="center">First Name </div></th> <th width="198"> <div align="center">Last Name </div></th> <th width="250"> <div align="center">Mobile Company </div></th> <th width="100"> <div align="center">Cell </div></th> <th width="100"> <div align="center">Workphone </div></th> <th width="100"> <div align="center">Group </div></th> </tr> <? echo "<form name='form1' method='post' action=''>"; while($objResult = mysql_fetch_array($objQuery)) { echo "<tr>"; echo "<td align='center'><input name=\"checkbox[]\" type=\"checkbox\" id=\"checkbox[]\" value=\"$objResult[addedrec_ID]\"></td>"; echo "<td>$objResult[addedrec_ID] </td>"; echo "<td>$objResult[FirstName]</td>"; echo "<td>$objResult[LastName] </td>"; echo "<td>$objResult[MobileCompany] </td>"; echo "<td>$objResult[Cell] </td>"; echo "<td>$objResult[WorkPhone] </td>"; echo "<td>$objResult[Custgroup] </td>"; echo "</tr>"; } echo "<td colspan='7' align='center'><input name=\"delete\" type=\"submit\" id=\"delete\" value=\"Delete\">"; if(isset($_POST['delete'])) // from button name="delete" { $checkbox = $_POST['checkbox']; //from name="checkbox[]" $countCheck = count($_POST['checkbox']); for($d=0;$d<$countCheck;$d++) { $del_id = $checkbox[$d]; $sql = "DELETE from UserAddedRecord where addedrec_ID = $del_id"; $result2=mysql_query($sql); } if($result2) { header('Location: customer-adddata.php'); } else { echo "Error: ".mysql_error(); } } echo "</form>"; ?> </table> <br> Total <?= $Num_Rows;?> Record : <?=$Num_Pages;?> Page : <? if($Prev_Page) { if($_GET["txtFirstName"] == "") { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtLastName=$_GET[txtLastName]'><< Back</a> "; } else { echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page&txtFirstName=$_GET[txtFirstName]'><< Back</a> "; } } for($i=1; $i<=$Num_Pages; $i++){ if($i != $Page) { echo "[ <a href='$_SERVER[SCRIPT_NAME]?Page=$i&txtFirstName=$_GET[txtFirstName]'>$i</a> ]"; } else { echo "<b> $i </b>"; } } if($Page!=$Num_Pages) { if($_GET["txtFirstName"] == "" && $_GET["txtLastName"] == "") { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtCell=$_GET[txtCell]'>Next>></a> "; } else if($_GET["txtFirstName"] == "" ) { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtLastName=$_GET[txtLastName]'>Next>></a> "; } else { echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page&txtFirstName=$_GET[txtFirstName]'>Next>></a> "; } } mysql_close($objConnect); } ?> </body> </html>
Thanks in advance.
Problem solved.
Thanks for everyone replied my question , here is my error:
Notice: Unknown column 'id' in 'order clause' in .....
I forgot to change my id here:
$strSQL .=" order by id DESC LIMIT $Page_Start , $Per_Page"; $objQuery = mysql_query($strSQL) or trigger_error(mysql_error());;
It should be:
$strSQL .=" order by addedrec_ID DESC LIMIT $Page_Start , $Per_Page";
Allow me to say thanks again and wish everyone a very good day .
最满意答案
您的查询以某种方式失败,并返回一个布尔值FALSE而不是语句句柄。 添加此内容以找出原因:
$query = mysql_query(...); if ($query === FALSE) { die(mysql_error()); }
永远不要假设数据库操作成功。
Your query has failed somehow, and returned a boolean FALSE instead of a statement handle. Add this to find out why:
$query = mysql_query(...); if ($query === FALSE) { die(mysql_error()); }
Never assume a database operation was successful.
相关问答
更多-
那实际上并不是mysql_fetch_array错误。 这个错误信息说这个函数的参数是错误的。 并且这个参数由mysql_query()函数返回 所以这意味着在查询执行过程中,在mysql端出现错误。 ans mysql有很多错误消息,相当丰富的。 因此,不要猜测 ,你必须联系一些能告诉你什么是错误的错误信息。 要实现这一点,请始终以这种方式运行查询: $sql = "SELECT * FROM persons"; $res = mysql_query($sql) or trigger_error(mysq ...
-
$query = "SELECT * FROM newuser WHERE token='$token'"; $result = mysql_query($query) or die(mysql_error()); while($row=mysql_fetch_array($result)) { do stuff... } 如果未执行die语句,则在进入while循环时$result是正常的。 那么问题可能是你在循环内部使用$result进行查询,最终导致它被设置为false。 $query = ...
-
确保 您正在选择数据库 您正在选择正确的列名称 你需要的地方有单引号。 Make sure You're selecting the database You're selecting the right column name You have single quotes where needed.
-
这是问题所在: $transaction_info = mysql_fetch_array($getTransaction, MYSQL_NUM); while($detail = mysql_fetch_array($transaction_info, MYSQL_NUM)){ 你正在调用mysql_fetch_array将信息加载到$transaction_info ; 然后你将这个相同的变量稍后传回mysql_fetch_array()几行。 我认为您只需要用以下代码替换这些代码行: wh ...
-
$query在while之前和while ...将变量的名称更改为$query2 ,例如: $hoje = strtotime(date("d-m-Y")); $db = new DBConfig(); $db -> config(); $db->conn(); $query = mysql_query("SELECT * FROM products WHERE auto_pub = ".$hoje) or die(mysql_error()); while($res = mysql_fetch_ass ...
-
您的查询可能有语法错误。 因此查询不会触发并返回false。 而你得到了这个错误:尝试引用id值: $kata = mysql_query("select * from `tag` where id='$teks2'"); Your query may have a syntax error. So query does not fire and returns false. And you get that error: Try to quote the id value: $kata = mysql_ ...
-
mysql_fetch_array()期望参数1是资源错误[重复](mysql_fetch_array() expects parameter 1 to be resource error [duplicate])[2022-08-18]
您的查询以某种方式失败,并返回一个布尔值FALSE而不是语句句柄。 添加此内容以找出原因: $query = mysql_query(...); if ($query === FALSE) { die(mysql_error()); } 永远不要假设数据库操作成功。 Your query has failed somehow, and returned a boolean FALSE instead of a statement handle. Add this to find out why: $ ... -
替换$veri = mysql_query("select ad,mesaj from yorum where id=$id") 。 在Variable parsing中: http : //php.net/manual/en/language.types.string.php When a string is specified in double quotes or with heredoc, variables are parsed within it. 此外,您尝试将mysql_*函数转换为PD ...
-
Mysql_fetch_array显示值为0或1的警告[重复](Mysql_fetch_array is showing a warning for values of 0 or 1 [duplicate])[2022-07-26]
正如评论所说,不再推荐使用mysql_系列函数。 但是,为了解释实际发生的事情: mysql_query不会直接返回你的计数结果,它会创建一个资源并返回一个数字标识符,其他mysql_函数将用它来获取该资源。 然后,错误消息告诉您,而不是资源,您有一个布尔值。 通常,这意味着您的mysql_query失败并返回false而不是资源标识符。 因此,您应首先检查结果是否为false并相应地运行。 例如,使用mysql_error检查查询的错误。 As the comments say, using the my ... -
$select_posts1= "SELECT FROM posts WHERE post_id = 1"; $select_posts2= "SELECT FROM posts WHERE post_id = 2"; $select_posts3= "SELECT FROM posts WHERE post_id = 3"; $select_posts4= "SELECT FROM posts WHERE post_id = 4"; $select_posts5= "SELECT FROM posts W ...