Possible Duplicate:
php warning mysql_fetch_assoc
I have tried my code and it seems to be working but it is throwing errors.
I'm in a LAMP environment, this is my code.
<?php
mysql_select_db($database_conn1, $conn1);
//DROPING VIEW
$query_rsDropView = "DROP VIEW attorneyOrder;";
echo $query_rsDropView . "/////"; //this code outputs nothing, not even the "/////" part.
$rsDropView = mysql_query($query_rsDropView, $conn1) or die(mysql_error());
echo $rsDropView . "/////"; //output the value "1" (witout quotes)
$row_rsDropView = mysql_fetch_assoc($rsDropView); //line 222
$totalRows_rsDropView = mysql_num_rows($rsDropView); //line 223
//CREATING VIEW
$query_rsView = "CREATE VIEW attorneyOrder AS SELECT * FROM LewisJohsAttorneys ORDER BY lname ASC;";
$rsView = mysql_query($query_rsView, $conn1) or die(mysql_error());
echo $rsView . "/////"; //outputs the value "1" (without quotes)
$row_rsView = mysql_fetch_assoc($rsView); //line 228
$totalRows_rsView = mysql_num_rows($rsView); //line 229
//GETTING VALUES FOR SELECT ON VIEW
$urlStart_rsName = "NULL";
if (isset($_GET['start'])) {
$urlStart_rsName = $_GET['start'];
}
$urlEnd_rsName = "NULL";
if (isset($_GET['end'])) {
$urlEnd_rsName = $_GET['end'];
}
//SELECTING DATA FROM VIEW
$query_rsName = sprintf("SELECT * FROM attorneyOrder WHERE attorneyOrder.lname BETWEEN %s AND %s;", GetSQLValueString($urlStart_rsName, "text"),GetSQLValueString($urlEnd_rsName, "text"));
$rsSearch = mysql_query($query_rsName, $conn1) or die(mysql_error());
echo $rsSearch . "/////"; //outputs a resouce id
$totalRows_rsName = mysql_num_rows($rsName); //line 249
//OUTPUTING DATA
while($rsSearch = mysql_fetch_assoc($rsSearch)){ //line 262
//do some stuff here
}
?>
The errors I'm getting are:
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 222
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 223
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 228
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 229
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 249
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /var/www/lewisjohs.com/attorneys-search.php on line 262
I'm assuming its all stemming from the same problem and that is why each successive query is returning an invalid value since they all build off of the prior ones output.
But, I'm still getting the correct output. I could just suppress the errors but I want to know why these errors are coming up. After searching online a common cause was not specifying the database, but that's the first thing I'm doing with this line [code]mysql_select_db($database_conn1, $conn1);[/code]
I tried outputing the return result of the queries and commented their output in the code. It seems they are appropriately returning either as "1" or true, or a resource id.