yakoup46 Posted April 7, 2010 Share Posted April 7, 2010 This code seems to work for Safari and Firefox, but in Internet Explorer I am getting the annoying "Query is Empty". Anyone know why? T.I.A <?php $con = mysql_connect("blah", "blah", "blah"); if (!$con) { die("Cound not connect: " . mysql_error()); } mysql_select_db("blah", $con); $check1 = $_POST["inputbox1"]; $check2 = $_POST["inputbox2"]; $check3 = $_POST["inputbox3"]; $check4 = $_POST["inputbox4"]; $check5 = $_POST["inputbox5"]; function checkib1() { if($check1 != 280) echo "Sorry! Wrong"; else echo "Correct!"; } function checkib2() { if($check1 != 2870) echo "Sorry! Wrong"; else echo "Correct!"; } function checkib3() { if($check1 != 820) echo "Sorry! Wrong"; else echo "Correct!"; } function checkib4() { if($check1 != -144) echo "Sorry! Wrong"; else echo "Correct!"; } function checkib5() { if($check1 != 1058) echo "Sorry! Wrong"; else echo "Correct!"; } if(isset($_POST['buttonsumofchain'])){ $sql="INSERT INTO Sumofchain VALUES ('$_POST[inputbox3]')"; checkib3(); } if(isset($_POST['buttonsumofdifference'])){ $sql="INSERT INTO Sumofdifference VALUES ('$_POST[inputbox4]')"; checkib4(); } if(isset($_POST['buttonsumofprimes'])){ $sql="INSERT INTO Sumofprimes VALUES ('$_POST[inputbox5]')"; checkib5(); } if(isset($_POST['buttonsumofsquares'])){ $sql="INSERT INTO Sumofsquares VALUES ('$_POST[inputbox2]')"; checkib2(); } if(isset($_POST['buttonsumofodds'])){ $sql="INSERT INTO Sumofodds VALUES ('$_POST[inputbox1]')"; checkib1(); } if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con) ?> Quote Link to comment https://forums.phpfreaks.com/topic/197917-query-is-empty/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 7, 2010 Share Posted April 7, 2010 You will find that it also does not work in Opera. This is because you are using images as your submit buttons and the HTML specification only states that the x,y coordinates where the image was clicked are to be submitted. Since you are using more than one button, you will need to use the buttonname_x variables in php to test which one was clicked on. See this link for how button data can be processed in php (AFAIK works in all browsers) - http://www.php.net/manual/en/faq.html.php#faq.html.form-image Quote Link to comment https://forums.phpfreaks.com/topic/197917-query-is-empty/#findComment-1038600 Share on other sites More sharing options...
yakoup46 Posted April 8, 2010 Author Share Posted April 8, 2010 I am using... type="submit" not type="image" Quote Link to comment https://forums.phpfreaks.com/topic/197917-query-is-empty/#findComment-1039037 Share on other sites More sharing options...
PFMaBiSmAd Posted April 8, 2010 Share Posted April 8, 2010 None of your buttonsumofchain, buttonsumofdifference, ... $_POST variables are set, so $sql is not being set and your code is blindly attempting to execute a query on an empty $sql variable, hence the error message. You need to troubleshoot what is wrong with your form. Since you did not post it, I gave the most likely cause for IE to behave differently. Best guess is that your HTML is invalid and other browsers ignore the error while IE does not. Quote Link to comment https://forums.phpfreaks.com/topic/197917-query-is-empty/#findComment-1039053 Share on other sites More sharing options...
yakoup46 Posted April 8, 2010 Author Share Posted April 8, 2010 If I use... if(!isset("blah")) Internet Explorer doesn't seem to mind, but Safari does. Would you like me to post my form? Quote Link to comment https://forums.phpfreaks.com/topic/197917-query-is-empty/#findComment-1039055 Share on other sites More sharing options...
yakoup46 Posted April 8, 2010 Author Share Posted April 8, 2010 if(!isset("blah")) Quote Link to comment https://forums.phpfreaks.com/topic/197917-query-is-empty/#findComment-1039056 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.