本文介绍了获取“提供的参数不是有效的 MySQL 结果资源";调用 mysql_fetch_array() 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不断收到相同的 mysql 错误代码,但我不知道如何更正.

I keep getting the same mysql error code but I dont know how to correct it.

错误:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /websites/123reg/LinuxPackage22/we/ez/y_/weezy.co.uk/public_html/search.php on line 29

我在下面的代码中标出了第 29 行.

I have marked out line 29 on the code below.

这是什么意思?

谢谢

<?php
// Change the fields below as per the requirements
$db_host="";
$db_username="";
$db_password="";
$db_name="";
$db_tb_name="data";
$db_tb_atr_name="name";
$db_tb_atr_name="email";
$db_tb_atr_name="location";


//Now we are going to write a script that will do search task
// leave the below fields as it is except while loop, which will display results on screen

mysql_connect("$db_host","$db_username","$db_password");
mysql_select_db("$db_name");

$query=mysql_real_escape_string($_GET['query']);

$query_for_result=mysql_query("

SELECT name, email, location

FROM data WHERE 

$db_tb_atr_name like '%".$query."%'");
echo "<h2>Search Results</h2><ol>";
while ($row = mysql_fetch_array($result))  <<<<<<<<<<<<<<< LINE 29 
{
echo "<li>";
echo substr($row["name"], $row["email"], $row["location"]);
echo "</li><hr/>";
}
echo "</ol>";

mysql_close();
?>

推荐答案

while ($row = mysql_fetch_array($result)) 

你在哪里将 $result 设置为任何东西?

Where have you set $result to anything?

你可能是说

while ($row = mysql_fetch_array($query_for_result))

这篇关于获取“提供的参数不是有效的 MySQL 结果资源";调用 mysql_fetch_array() 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 22:05