mysql query using global variables
- by Carlos
I am trying run a query to active the users account. I am not sure if I am having problem with the query itself or if there's something else that I dont know about. here is the code:
if($_SESSION['lastid']&&$_SESSION['random'])
{
$check= mysql_query('SELECT * FROM members WHERE id= "$_SESSION[lastid]" AND random = " $_SESSION[random]"');
$checknum = mysql_num_rows($check);
//$checknum = mysql_query($check) or die("Error: ". mysql_error(). " with query ". $check);
if($checknum != 0) // run query to activate the account
{
$acti= mysql_query('UPDATE members SET activation = "1" WHERE id= "$_SESSION[lastid]"');
die('Your account has been activated. You may now log in!');
}else{
echo('Invalid id or activation code.') . ' lastid: ' .$_SESSION['lastid'] . ' random: ' .$_SESSION['random'] ;
// die ('Invalid id or activation code.');
}
}else{
die('Could not either find id or random number!');
}
this is the warning I am getting from mysql:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /hermes/bosweb26b/b2501/servername/folder/file.php on line 30
but when I echo the variables out, I get the same values that are stored in the database....
Invalid id or activation code. lastid: 2 and random: 36308075
could someone please give me a hint?
thank you.