Re[2]: [PHP-DB] Search tutroial

From: Date: Wed, 24 Apr 2002 18:53:13 +0000
Subject: Re[2]: [PHP-DB] Search tutroial
References: 1 2 3 4  Groups: php.db 
Request: Send a blank email to php-db+get-18783@lists.php.net to get a copy of this message
JD> By the way SELECT uid, id, image, iname, quantity, type, user where it shows JD> below that user isn't in the query- it is there in my editor. >> $query = "SELECT uid, id, image, iname, quantity, type FROM >> {$config["prefix"]}_shop WHERE iname = $shopsearch"; The first problem would be that your search string needs to be enclosed in quotes, preferably single, or at the very least escaped double quotes. Presumably, you want to find things that are inexact matches, but darn close, and in that case you can use LIKE in your query. Look in the MySQL manual for the various permutations of LIKE clauses. But fundamentally, you should to throw in an "or die(mysql_error())" in conjunction with your mysql_query function. IE: $ret = mysql_query($query) or die(mysql_error()); This will tell you exactly the problem when executing a query. And as others have said, another fine way to debug your queries is to simply echo them to the screen, look at what is being sent to MySQL, and trying it manually if the problem isn't glaringly obvious. But first, surround your search term with quotes and see how far you get. - Julie --> Julie Meloni --> julie@thickbook.com --> www.thickbook.com Find "Sams Teach Yourself MySQL in 24 Hours" at http://www.amazon.com/exec/obidos/ASIN/0672323494/thickbookcom-20

« previous php.db (#18783) next »