RE: [PHP-DB] mysql_num_rows
| From: | Swan, Nicole | Date: | Wed, 03 Mar 2004 20:05:02 +0000 |
| Subject: | RE: [PHP-DB] mysql_num_rows | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-33267@lists.php.net to get a copy of this message | ||
From a quick glance, I noticed that you have commented out the code that does the actual query
against the MySQL database. This is the line:
// $result = mysql_query($query, $db);
Without this statement, there is no query to the database. It should be:
$result = mysql_query($query); //without specifying a database link, it will use the available one
The $result variable will then hold a result identifier that should be used throughout your code
from then on (i.e. any place you currently have $query). For example:
mysql_num_rows($result)
or
mysql_result($result, 0, 'user_id');
--Nicole
---------------------------
Nicole Swan
Web Programming Specialist
Carroll College CCIT
(406)447-4310
-----Original Message-----
From: Craig Hoffman [mailto:choffman@katomic.com]
Sent: Wednesday, March 03, 2004 12:50 PM
To: php-db@lists.php.net
Subject: Spam:[PHP-DB] mysql_num_rows
Perhaps someone could look at this function and help me trouble shoot
it? This function notifies the user of their new passwd.
I keep getting an error message on this page (see below). What's
strange is the script seems to be working because i am getting an
email with my new password. Here is the error message I am receiving:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL
result resource in
/Users/choffman/Sites/www/cyclistsedge/include/
forgot_password_functions.php on line 70
suggestions? Anything will be helpful. Much Thanks CH
function notify_password($username, $password)
// notify the user that their password has been changed
{
$query ="SELECT username FROM users WHERE username=('$username')";
// $result = mysql_query($query, $db);
if (!$query)
{
return false; // not changed
}
line 70 => else if (mysql_num_rows($query)==1)
$user_id = mysql_result($query, 0, 'user_id');
$from = "From: missy@cyclistsedge.com \r\n";
$mesg = "Your password has been changed to $password \r\n"
."You might want to change it next time you log in. \r\n";
if (mail($username, 'Cyclists Edge login information', $mesg,
$from))
return true;
else
return false;
}
__________________________________
Craig Hoffman - eClimb Media
v: (847) 644 - 8914
f: (847) 866 - 1946
e: choffman@eclimb.net
w: www.eclimb.net
_________________________________
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php