Jump to content

[SOLVED] Should Have Same Values


FlyingIsFun1217

Recommended Posts

Hey!

 

I've got code that is supposed to get values from a cookie, check a database table to see if the values from the cookie are in there/the same, and proceed if everything worked out. But somehow, it's telling me that they are both null:

 

$cookieUser = $_GET['user'];
$cookiePass = $_GET['password'];

$sqlUser = 'SELECT user, passmd5 FROM users WHERE user="'.$cookieUser.'"';
$userData = mysql_fetch_array(mysql_query($sqlUser), MYSQL_ASSOC);

if($userData['user'] == $cookieUser && $userData['passmd5'] == $cookiePass)
{
          //Success! What it should be doing
}

 

I've double-checked that the values in my cookies (both 'user' and 'password') are the same as the values present in the database, and yet still it tells me they are both null-valued. :/

 

Thanks for the help!

Link to comment
https://forums.phpfreaks.com/topic/111935-solved-should-have-same-values/
Share on other sites

Try

 

$cookieUser = $_GET['user'];
$cookiePass = $_GET['password'];

$sqlUser = 'SELECT user, passmd5 FROM users WHERE user="'.$cookieUser.'"';
$result = mysql_query($sqlUser) or die(mysql_error());
$userData = mysql_fetch_array($result, MYSQL_ASSOC);

if($userData['user'] == $cookieUser && $userData['passmd5'] == $cookiePass)
{
          //Success! What it should be doing
}

 

 

that should give an error if the query is wrong.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.