Jump to content

Query was empty


harkly

Recommended Posts

I am trying to update a field with a random number, it will then send it in an email. I need help with it updating the database. I got the rest working.

 

Not sure how much code is needed but here is where my problem lies--

 

if($error == 0)

{

  $sql_check = mysql_query("SELECT pswd, userID FROM user WHERE email='".$email."'") or die(mysql_error());

  while ($r=mysql_fetch_array($sql_check))
    $userID=$r["userID"];
    $pswd=mt_rand(10000, 999999);


if($forgot == "password")
{


$sql = "UPDATE user SET pswd='$pswd' WHERE email='$email' or die(mysql_error())";
$result = mysql_query($query) or die(mysql_error());



//These are the variables for the email 

  $to = $email; // this is the email address collected form the form 

  $subject = "email confirmation";

$message = "Your new password $pswd " ;

  $header = "From: [email protected]\r\n"; 

  $header .= "Reply-to: [email protected]\r\n"; 


// This is the function to send the email 

  if (mail($to, $subject, $message, $header))
   {
    echo "<p>Message successfully sent!</p>";
   }
  else
   {
    echo "<p>Message delivery failed...</p>";
   }
}

 

 

WHen I add these lines is when my error happens

 

$sql = "UPDATE user SET pswd='$pswd' WHERE email='$email' or die(mysql_error())";
$result = mysql_query($query) or die(mysql_error());

 

This gives me the error -- Query was empty

Link to comment
https://forums.phpfreaks.com/topic/192418-query-was-empty/
Share on other sites

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.