PDA

View Full Version : mysql_fetch_array(): supplied argument is not a valid MySQL result resource


blama
11-07-2007, 12:34 AM
Hey there....trying to make what I think is a fairly simple php/mysql script.

{
$dateecho = mysql_query("SELECT * FROM `sleeveid` WHERE date =" . $date . "");
$cityecho = mysql_query("SELECT * FROM `sleeveid` WHERE city =" . $city . "");
$stateecho = mysql_query("SELECT * FROM `sleeveid` WHERE state =" . $state . "");
$bigidecho = mysql_query("SELECT * FROM `sleeveid` WHERE bigid =" . $bigid . "");
$smallidecho = mysql_query("SELECT * FROM `sleeveid` WHERE smallid =" . $smallid . "");
$result_date = mysql_fetch_array( $dateecho );
$result_city = mysql_fetch_array( $cityecho );
$result_state = mysql_fetch_array( $stateecho );
$result_bigid = mysql_fetch_array( $bigidecho );
$result_smallid = mysql_fetch_array( $smallidecho );

{
echo "<td>" . $result_date['date'] . "</td>";
echo "<td>" . $result_bigid['bigid'] . "</td>";
echo "<td>" . $result_smallid['smallid'] . "</td>";
echo "<td>" . $result_city['city'] . " , " . $result_state['state'] . "</td>";
}
}


I get the argument error in the following three:

$result_date = mysql_fetch_array( $dateecho );
$result_city = mysql_fetch_array( $cityecho );
$result_state = mysql_fetch_array( $stateecho );

However, the last one (smallid), although there is no error for it...it doesn't display/echo.


Any ideas? I'm fairly noob at php and learn by looking at other code and adapting it for myself.

Thanks...



P.S. the idea of the script is to show all the cities and states accociated with a particular ID. A good example or similar one at least would be wheresgeorge (http://www.wheresgeorge.com/report.php?key=18cb84597b7b64edeb734317cea9bf6b88f9e9db85dbe7b0).

Fumigator
11-07-2007, 01:03 AM
Since you're noob to MySQL and PHP then you get one free pass.

Just about everything about your logic is wrong. You should have one and only one query, and that one query should select the fields you desire. You need to do some reading and studying on how relational databases work and how the SQL language works. A good place to start is Google.