-2

here's a part of my code.

if(isset($_GET['processit'])) {
if($_GET['processit']=='validation') {
    $validcode = $_GET['acode'];
    //get all the data.
    $validquery = mysql_query("sleect * from tempuserinfo where activation_code ='$validcode'", $db);

    //put into row
        $rowxx = mysql_fetch_assoc($validquery);
        $user_firstname = $rowxx['user_firstname'];
        $user_middlename = $rowxx['user_middlename'];
        $user_lastname = $rowxx['user_lastname'];

    echo $user_firstname;
    echo $user_middlename;
   }
  }
?>

And on my table it only has one row. But im having the Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in /home/u778649338/public_html/reservation/reservationkitchen.php on line 381

error. I wonder what is wrong?

thanks in advance.

Krish R
  • 22,188
  • 7
  • 49
  • 57
CudoX
  • 953
  • 2
  • 18
  • 31

1 Answers1

0

You have typo in your mysql query;

$validquery = mysql_query("sleect * from tempuserinfo where activation_code ='$validcode'", $db);

should be

$validquery = mysql_query("select * from tempuserinfo where activation_code ='$validcode'", $db);

You should always escape variables in query which are provided from user input. mysql_* functions are deprecated, you should use PDO or MySQLi instead. However, if you must use the old library, escape user inputs with mysql_real_escape_string.

$validcode = mysql_real_escape_string($_GET['acode']);
Patrick Q
  • 6,374
  • 2
  • 24
  • 34
aksu
  • 5,163
  • 5
  • 22
  • 38