Help... Error: Query was empty using INSERT INTO
Posted: Thu Feb 11, 2010 2:11 pm
Hello,
I have looked this code over several times and cannot seem to find the issue.
I am trying to insert some form data into my MYSQL database and continually get the error
"Error: Query was empty"
Here is my code:
Thanks in advance!!
I have looked this code over several times and cannot seem to find the issue.
I am trying to insert some form data into my MYSQL database and continually get the error
"Error: Query was empty"
Here is my code:
Code: Select all
<?php
ini_set("date.timezone","America/New_York");
//login to mysql
require_once('con/con.php');
mysql_select_db("abc_abc" , $con)
or die("Couldn't open $db: ".mysql_error());
$when = date("D dS M,Y h:i a");
if ( $_SERVER["REQUEST_METHOD"]=="POST" ) {
$addme1 = mysql_real_escape_string ($_POST["ADD_ME"]);
$date1 = mysql_real_escape_string ($_POST["date"]);
$title1 = mysql_real_escape_string ($_POST["title"]);
$industry1 = mysql_real_escape_string ($_POST["industry"]);
$use1 = mysql_real_escape_string ($_POST["use"]);
$collection1 = mysql_real_escape_string ($_POST["collection"]);
$res1 = mysql_real_escape_string ($_POST["resolutions"]);
$upld1 = mysql_real_escape_string ($_POST["uploadedfile"]);
$url1 = mysql_real_escape_string (basename( $_FILES['uploadedfile']['name']));
}
//UPLOAD FILE
if (isset($url1))
{
$target_path = "templates/";
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']).
" has been uploaded";
} else{
echo "There was an error uploading the file, please try again!";
}
}
//ADD INFO TO MYSQL
if (isset($_POST['ADD_ME']))
{
mysql_query("INSERT INTO designer (DATE, RESOLUTION, TITLE, URL, INDUSTRY, USE, COLLECTION)
VALUES ('$date1', '$res1', '$title1', '$url1', '$industry1', '$use1', '$collection1')");
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "1 record added";
//variables below are to ensure correct posting
echo "TEMPLATE SUCESSFULLY ADDED!";
echo $addme1;
echo $date1;
echo $title1;
echo $industry1;
echo $use1;
echo $collection1;
echo $res1;
echo $upld1;
echo $url1;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Add Template</title>
</head>
<body>
<h2>Please Populate ALL The Fields Below To Add A New Template:</h2>
<form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST">
<input type="hidden" name="ADD_ME" value="ADD_ME">
<input type="hidden" name="date" value="<? echo "$when" ?>">
Title:<br><input type="text" name="title" size="60" value=""><br>
Industry:<br>
<select name="industry">
<option selected>Choose</option>
<option value="Hotel">Hotel</option>
<option value="Resturant/Cafe">Resturant/Cafe</option>
<option value="Convention Center">Convention Center</option>
<option value="Airport">Airport</option>
<option value="Retail">Retail</option>
<option value="Government">Government</option>
<option value="Education">Education</option>
<option value="Medical">Medical</option>
<option value="Sports Entertainment">Sports Entertainment</option>
<option value="Casino">Casino</option>
<option value="Museum/Zoo">Museum/Zoo</option>
</select><br>
Use:<br><input type="text" name="use" size="15" value=""><br>
Collection:<br>
<select name="collection">
<option selected>Choose</option>
<option value="Abstract">Abstract</option>
<option value="Emergency">Emergency</option>
<option value="Frame">Frame</option>
<option value="Fresco">Fresco</option>
<option value="Misc">Misc.</option>
</select><br>
Resolution:<br>
<select name="resolutions">
<option selected>Choose</option>
<option value="800x600">800x600</option>
<option value="1024x768">1024x768</option>
<option value="1280x720">1280x720</option>
<option value="1280x768">1280x768</option>
<option value="1280x1024">1280x1024</option>
<option value="1360x768">1360x768</option>
<option value="1366x768">1366x768</option>
<option value="1440x900">1440x900</option>
<option value="1600x1200">1600x1200</option>
<option value="1920x1080">1920x1080</option>
<option value="1920x1200">1920x1200</option>
</select><br>
<h2>Template Upload</h2>
<input type="hidden" name="MAX_FILE_SIZE" value="100000" />
Choose a template to upload: <input name="uploadedfile" type="file" /><br />
</p><hr>
<br />
<input type="submit" name="submit_btn" value="ADD TEMPLATE" />
<input type="reset" value="RESET">
</form>
</body>
</html>