Jump to content

Recommended Posts

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)

?>

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

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

Link to comment
https://forums.phpfreaks.com/topic/197917-query-is-empty/#findComment-1038600
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/197917-query-is-empty/#findComment-1039053
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.