Re: Shot in the dark

From: Date: Mon, 17 Jun 2002 20:11:22 +0000
Subject: Re: Shot in the dark
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-102590@lists.php.net to get a copy of this message
Correct, you need to surround such strings with ' ' in an SQL query. -Rasmus On Sat, 6 Jul 2002, jtjohnston wrote: > Rasmus, > > Warning: Supplied argument is not a valid MySQL result resource in c:\program > files\easyphp\ccl_www\db1\index.html on line 45 > You have an error in your SQL syntax near ' Margaret order by AU desc' at line 1 > > So it doesn't like my "," (comma) ? > > $au ="Atwood, Margaret"; > $id ="1624"; > > #$news = mysql_query('select * from '.$table.' where id like '.$id.' > order by AU desc'); > $news = mysql_query('select * from '.$table.' where AU like '.$au.' > order by AU desc'); > #$news = mysql_query('SELECT * FROM '.$table.' WHERE MATCH (AU) AGAINST > ('.$au.' IN BOOLEAN MODE) order by AU desc'); > > while ($mydata = mysql_fetch_object($news)) > { > $mycounter++; > echo $mydata->id." - ".$mydata->AU."<hr>"; > } > > if(!$news) die(mysql_error()); > > > > > Lerdorf wrote: > > > If you added some error-checking you'd know right away. > > > > ie. after your mysql_query() call. > > > > if(!$news) die(mysql_error()); > > > > -Rasmus > > > > On Sat, 6 Jul 2002, jtjohnston wrote: > > > > > MySQL4 installation. I don't get this. One mysql_query works, the other > > > 2 don't. What did I mess up in my PHP syntax? > > > The SQL queries all work. > > > > > > $au ="Atwood, Margaret"; > > > $id ="1624"; > > > > > > THIS WORKS: > > > $news = mysql_query('select * from '.$table.' where id like > > > '.$id.' > > > order by AU desc'); > > > > > > This gives "Warning: Supplied argument is not a valid MySQL result > > > resource ... on line 48": > > > $news = mysql_query('select * from '.$table.' where AU like > > > '.$au.' > > > order by AU desc'); > > > #SQL-Query works: select * from ccl_main where AU like 'Atwood, > > > Margaret' order by AU desc > > > > > > This gives "Warning: Supplied argument is not a valid MySQL result > > > resource ... on line 48": > > > $news = mysql_query('SELECT * FROM '.$table.' WHERE MATCH (AU) AGAINST > > > ('.$au.' IN BOOLEAN MODE) order by AU desc`'); > > > #SQL-Query works: SELECT * FROM ccl_main WHERE MATCH (AU) AGAINST > > > ('Atwood, Margaret' IN BOOLEAN MODE) order by AU desc > > > > > > while ($mydata = mysql_fetch_object($news)) <----- this is line > > > 48 > > > { > > > $mycounter++; > > > echo $mydata->id." - ".$mydata->AU."<hr>"; > > > } > > > > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#102590) next »