RE: [PHP-DB] mysql_query troubles
| From: | Karl Phillipson | Date: | Tue, 17 Jul 2001 07:30:49 +0000 |
| Subject: | RE: [PHP-DB] mysql_query troubles | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-10512@lists.php.net to get a copy of this message | ||
Brad,
Have you defined the database variable you are connecting to?
ie: $DB="your_database_name"; and then connecting:
if(!($testResult = mysql_query($DB, "SELECT * FROM login_table where Pass =
password('$password')")))
try the code snippet below and see if it spits an error at you - you will
need to define the $DB variable.
<?
//error reporting function
function DisplayErrMsg ( $message )
{
sprintf("<BLOCKQUOTE><BLOCKQUOTE><BLOCKQUOTE><H3>%s</H3></BLOCKQUOTE></BLOCK
QUOTE></BLOCKQUOTE>\n", $message);
}
//begin query
if(!($testResult = mysql_query($DB, "SELECT * FROM login_table where Pass =
password('$password')")))
//if we get an error print it
{
DisplayErrMsg(sprintf("internal error %d:%s\n",
mysql_errno(), mysql_error()));
exit();
}
$num_rows = mysql_num_rows($testResult);
print "$num_rows";
exit();
mysql_free_result($testResult);
?>
-----Original Message-----
From: Brad Wright [mailto:bradwright@optushome.com.au]
Sent: 17 July 2001 06:31
To: php-db@lists.php.net
Subject: [PHP-DB] mysql_query troubles
Hi all',
I have a mysql_query that reads:
$testResult = mysql_query("SELECT * FROM login_table where Pass =
password('$password')") or die ("ouch");
$num_rows = mysql_num_rows($testResult);
the problem is that I keep getting a value of 0 for $num_rows when I know
the table has 1 entry for PAss which equals password('$password'). The
password I have used is just 'a' (before pasing throught the password
function in the insert).
I DO have a table named login_table
I KNOW that there is an entry that matches 'password('$password)'.. ( i
checked using phpMyAdmin)
can anyone help??????
Thanks in advance,
brad
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
For additional commands, e-mail: php-db-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net