From: nathan_jackson at iprimus dot com dot au
Operating system: Windows XP
PHP version: 4.3.3
PHP Bug Type: MySQL related
Bug description: problem with mysql_fetch_object()
Description:
------------
I am trying to login a user. I want to get the users name and account type
from the database the store them in a cookie.
I am recieving this message when I try to run the script:
"Warning: mysql_fetch_object(): supplied argument is not a valid MySQL
result resource in C:\Project\Music Manager\check_login.php on line 14"
I am using IIS on Windows XP.
Reproduce code:
---------------
$password = crypt($HTTP_POST_VARS["password"]);
$connec = mysql_connect("localhost", "root", "farmer01");
mysql_select_db("onlinedb");
$data = mysql_query( "SELECT username, name_first,
name_last, acc_type FROM user
WHERE username
= ".$HTTP_POST_VARS['username']."
AND password = ".$password."");
If (!$data){
header("Location: /err_login.php"); }
else {
$row = mysql_fetch_object($data);
$values = "".$row->username."|".$row->name_first.
"|".$row->name_last."|".$row->acc_type."";
setcookie( "user", $values );
}
mysql_close($connec);
Expected result:
----------------
I was expecting that all of the values above would have been placed into
the cookies "user"as a string. To later be seperated by the explode()
function.
Actual result:
--------------
I recieved this message:
"Warning: mysql_fetch_object(): supplied argument is not a valid MySQL
result resource in C:\Project\...\check_login.php on line 14"
--
Edit bug report at http://bugs.php.net/?id=26088&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=26088&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=26088&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=26088&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=26088&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=26088&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=26088&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=26088&r=support
Expected behavior: http://bugs.php.net/fix.php?id=26088&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=26088&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=26088&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=26088&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26088&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=26088&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=26088&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=26088&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26088&r=float