RE: [PHP-DB] Re: PHP advice
| From: | David Redmond | Date: | Tue, 26 Feb 2002 02:00:13 +0000 |
| Subject: | RE: [PHP-DB] Re: PHP advice | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-17288@lists.php.net to get a copy of this message | ||
You should enclose any string that you searching on within a ' and '
Your SQL query should look something like;
$query = "SELECT * FROM auth WHERE password = '". $password ."'";
Cheers
"Greg Lobring" <globring@hotmail.com> wrote in message
news:F116N28f45wSz6btzsY000059bb@hotmail.com...
> I dont understand why this is causing me so much trouble, hopefully
someone
> can help. I have a simple PHP script that takes the user id and password
> from a form on a page...here is the php used after submitting the form:
>
> <?
> @ $db = mysql_pconnect("localhost", "blah", "blah");
> if (!$db)
> {
> echo "Error: Could not connect to database.";
> exit;
> }
> mysql_select_db("blahblah");
> $query = "select * from auth where password = ".$password."";
> $result = mysql_query($query);
> $num_results = mysql_num_rows($result);
> echo "Number of Rows: ".$num_results."";
> mysql_close($db);
> ?>
>
> It connects fine, and when the query returns NO (0) rows, it appears
> correct. However, when the query returns a record, I get the following
> error:
>
>
> Warning: Supplied argument is not a valid MySQL result resource in
picks.php
> on line 16
>
> Where line 16 is the the line that says $num_results =
> mysql_num_rows($result);
>
>
> Does anyone have any advice?
>
> Appreciated in advance..
>
> Greg
>
>
>
> _________________________________________________________________
> Chat with friends online, try MSN Messenger:
> http://messenger.msn.com
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php