数据库连接都是正确的,但我收到一条错误消息
Warning:
mysql_fetch_array(): supplied argument is not a valid MySQL result on line 31
<?php
$hostname = "localhost";
$username = "user";
$password = "pass";
$usertable = "products";
$dbName = "test_prods";
$s = $_GET["s"];
$name = $row["product_name"];
MYSQL_CONNECT($hostname, $username, $password) OR DIE("Unable to connect to database");
@mysql_select_db( "$dbName") or die( "Unable to select database");
//error message (not found message)
$XX = "No Products Found";
$query = mysql_query("SELECT * FROM $usertable WHERE $s LIKE '$name'");
while ($row = mysql_fetch_array($query))
{
$variable1=$row["row_name1"];
$variable2=$row["row_name2"];
$variable3=$row["row_name3"];
print ("this is for $variable1, and this print the $variable2 end so on...");
}
//below this is the function for no record!!
if (!$variable1)
{
print ("$XX");
}
//end
?>