Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199908

[PHP3] RE: NEWBIE: PHP search of MySQL From: Samuel Leibowitz (sleibowitz <email protected>)
Date: 08/12/99

John,

If you haven't tried it already, try adding the line
        print mysql_error()."\n";
just before your while loop. It'll print out any errors returned by the
MySQL server.

If there are no errors reported by mysql_error(), you might want to try
logging into the server interactively (using the cmd-line MySQL client) to
try running a couple sample queries. Usually, however, I find that if
errors aren't being reported, it's because I've made a logical mistake
("oops - I guess I mis-set the counter variable") rather than a syntactic
one ("oops - I mis-spelled my column names").

Hope this helps,

Sam Leibowitz
sleibowitz <email protected>

> -----Original Message-----
> From: John Cherbini [mailto:johnc <email protected>]
> Sent: Wednesday, August 11, 1999 3:04 PM
> To: php3 <email protected>
> Subject: NEWBIE: PHP search of MySQL
>
>
> Hello all,
>
> This SQL query is giving me some trouble. In its current incarnation, it
> returns a blank page with the search variable at the top.
> --------------------------------------
> if ($search) {
> echo $search;
> $result = mysql_query("SELECT
> img_url,location,comment,o
> ther FROM pics WHERE img_url = '$search' or location = '$search'
> or comment = '$
> search' or other = '$search'");
>
> $number = mysql_numrows($result);
>
> $i = 0;
>
> while ( $i < $number ) {
>
> $url= mysql_result($result, $i, "img_url");
> $location= mysql_result($result, $i, "location");
> $comment= mysql_result($result, $i, "comment");
> $other= mysql_result($result, $i, "other");
> --------------------------------------------
>
> I use ' (single quote) around the WHERE terms and NOT ` (backquotes)
>
> If I use backquotes I get a query error.
>
> $search returns the correct variable.......
>
> What am I not doing correctly?
>
> Many thanks!
>
> John
>
>
> --
> ---------------------------------
> John Cherbini
> http://www.bajaspa.com
> http://www.webzone.net/gcc
>

-- 
PHP 3 Mailing List <http://www.php.net/>
To unsubscribe, send an empty message to php3-unsubscribe <email protected>
To subscribe to the digest, e-mail: php3-digest-subscribe <email protected>
To search the mailing list archive, go to: http://www.php.net/mailsearch.php3
To contact the list administrators, e-mail: php-list-admin <email protected>