sql server - PHP SQL Not updating row in database -


i'm making simple script takes user input named comments , putting in database. every time use same email, want overwrite last entry. however, keeps putting new entry every time. here code:

if($comments){     try{         echo "<img width=\"245\" height=\"130\" src=\"logo.png\"/><br/>";         echo "<h1>thank you. should receive order on xx-xx-xx</h1>";         $tf = "true";         if($numrows == 0){             $postquery = "insert ttt25 (email,card,changes,comments) values ('$email','$businesscard','$tf','$comments')";             $querythepost = sqlsrv_query($conn, $postquery);         }         else{             $postquery = "update ttt25 set changes = '$tf', comments = '$comments' email = '$email'";             $querythepost = sqlsrv_query($conn, $postquery);         }      }     catch(exception $e){} }  elseif($optout=="false"){     echo "<img width=\"245\" height=\"130\" src=\"logo.png\"/><br/>";     echo "<h1>thank you. should receive order on xx-xx-xx</h1>";     $tf = "false";     $comments = "";     if($numrows == 0){     $postquery = "insert ttt25 (email,card,changes,comments) values ('$email','$businesscard','$tf','$comments')";     $querythepost = sqlsrv_query($conn, $postquery);     }     else{     $postquery = "update ttt25 set changes = '$tf', comments = '$comments' email = '$email'";     $querythepost = sqlsrv_query($conn, $postquery);     } } 

sorry must have cut off: num rows , other variables defined before conditional statements:

$optout = $_get['opt']; $encodedemail = $_get['email']; $email = base64_decode($encodedemail); $originalcard = base64_decode($_get['card']); $businesscard = $originalcard; $comments = $_post['comments']; //$primary = md5(uniqid(rand (), true)); no longer needed $postquery; $tf; $sqlmatch = sqlsrv_query("select * ttt25 email = '".$email."'"); $numrows = sqlsrv_num_rows($sqlmatch); echo $numrows; 


Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -