Re: Frustrating ?

From: Date: Mon, 18 Feb 2002 06:48:02 +0000
Subject: Re: Frustrating ?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-85163@lists.php.net to get a copy of this message
In article <3C709F7D.E7A5C20B@collegesherbrooke.qc.ca>, taylorjo@collegesherbrooke.qc.ca (Jtjohnston) wrote: > Heres's a frustrating, and maybe not so stupid question? > > I'm getting "Warning: Supplied argument is not a valid MySQL result > resource" on this line: > > while ($mydata = mysql_fetch_object($news)) > > So what am I doing wrong here: > > $where = "id like $id"; > $news = mysql_query('select * from ccl where '.$where.' order by AU > desc'); //desc => z-a A) Have you already confirmed that a valid database connection was made? B) String values in mysql have to be quoted. For example, "where foo='bar'" or "where foo like 'bar%'". C) Error checking on database operations is a really good idea. Even just a short "or die()" on the mysql_* calls can help you track down problems much more effectively. For example: $result=mysql_query($sql) or die("MySQL reports error: ". mysql_error() . " for query " . htmlentities($sql)); For more sophisticated error handling, see <http://www.php.net/manual/en/ref.errorfunc.php>. -- CC

« previous php.general (#85163) next »