Help with Query

I’m having problem with the script below. The if(!$emailresult) {
statement doesn’t seem to be working the way I expect. When I run this script with no match between AVName and $name it should send the echo message that the name wasn’t found, but it’s always skipping to the else statement. Hope this makes sense. Thanks in advance.

<?php $hostname = "mysql.mydebitcredit.com"; // eg. mysql.yourdomain.com (unique) $username = "shornik"; // the username specified when setting-up the database $password = "ginger"; // the password specified when setting-up the database $database = "secondlife_2021"; // the database name chosen when setting-up the database $tablename1 ="AccountingEquation_sl4"; //the table to store HW $emailmessage = "Thank you, your HW has been received and processed and is shown as it is stored in my files. Please note that I have inserted commas in between each part of your transaction. This helps with my grading. If you wish to re-submit your assignment you can up until the due date, any old submission will automatically be deleted from my system and your most recent one will take its place. Dr. Hornik"; //The message to send $processflag = "true"; //Flag set to true to indicate no records are currently being processed if ($processflag == "false"){ exit("resend"); //if exit code is resend then a record is being processed, have lsl resend } $link = mysql_connect($hostname,$username,$password); mysql_select_db('secondlife_2021'); // get things from $_POST[] // Naturally enough, if this is empty, you won't get anything $processflag = "false"; // set flag to indicate a record is being processed $Name = $_POST["AVName"]; $AVKey = $_POST["AVKey"]; $NoteCard = $_POST["NoteCardName"]; $Answer = $_POST["Answer"]; $Account = $_POST["AccountNumber"]; $DebitorCredit =$_POST["DebitCredit"]; $Amount =$_POST["Amount"]; $Date =$_POST["DateSubmitted"]; $NoteKey =$_POST['NoteCardKey']; $Time =$_POST['TimeStamp']; $DeleteQuery = "DELETE FROM $tablename1 WHERE AVName = '".$Name."'"; $deleteResult = mysql_query($DeleteQuery); $QueryAdd = "INSERT INTO $tablename1 (AVName, AVKey, NoteCardName, NoteCardKey, Answer, AccountNumber, DebitCredit, Amount, DateSubmitted, TimeStamp) VALUES ('$Name', '$AVKey', '$NoteCard', '$NoteKey','$Answer', '$Account', '$DebitorCredit', '$Amount', '$Date', '$Time')"; $result = mysql_query($QueryAdd); if (!$result) { die('Invalid query: ' . mysql_error()); } $processflag = "true"; $QueryEmail ="SELECT * FROM 2021_Names WHERE AVName = '".$Name."'"; $emailresult = mysql_query($QueryEmail); //echo $emailresult; if(!$emailresult) { echo "Your avatar name has not been recorded in my system, therefore no confirmation email can be sent, please go to http: and update your informatiion"; die('Invalid Email query: ' . mysql_error()); } else { echo "Thanks, your data has been stored and an email confirmation has been sent to you"; $row = mysql_fetch_row($emailresult); mail($row[4],'SL homework 4', $Answer . $emailmessage); } mysql_close($link); ?>
Sponsor our Newsletter | Privacy Policy | Terms of Service