Re: Could some one check my code

From: Date: Wed, 26 Nov 2003 12:21:41 +0000
Subject: Re: Could some one check my code
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-171036@lists.php.net to get a copy of this message
PAUL FERRIE wrote:
i am getting this error returned but i dont know why :( error: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/pferrie/public_html/vinrev/adm/insert2.php on line 6 php file <?php include("connection.php"); if(!empty($rating)){ $query="SELECT * FROM $tablename WHERE rating = '$rating'"; if(mysql_query($query)) { $myrow = mysql_fetch_array($query);// This line returns an error!
You need to capture the return value of mysql_query(). mysql_query() is going to return a Resource that should be passed to mysql_fetch_array(), so it knows where to get each row from. if($result = mysql_query($query)) { $myrow = mysql_fetch_array($result); -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#171036) next »