Could not add the entry???
Posted: Fri Oct 27, 2006 7:03 pm
I am getting the following when I test the code that is below:
Could not add the entry because: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' )' at line 1. The query was INSERT INTO tbl_testing (id, photo, phototype) VALUES (0, , ). Can someone please help me solve this problem? Thanks in advance.
Here is the code for adding a filename to the database:
This is the form:
Could not add the entry because: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' )' at line 1. The query was INSERT INTO tbl_testing (id, photo, phototype) VALUES (0, , ). Can someone please help me solve this problem? Thanks in advance.
Here is the code for adding a filename to the database:
Code: Select all
require "config.php";
if (isset($_POST['Submit'])) {
$filename = $_POST['filename'];
$type = filetype($filename);
$insert = "INSERT INTO tbl_testing (id, photo, phototype) VALUES (0, $filename, $type)";
if (mysql_query($insert)) {
header ('Location: tested.php');
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $insert.</p>";
}
}
mysql_close();Code: Select all
<form action="<?php echo $PHP_SELF; ?>" method="post" enctype="multipart/form-data" name="testingform">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="15%">Filename</td>
<td width="85%"><input name="filename" type="file" id="filename"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="Submit" value="SUBMIT" id="Submit"></td>
</tr>
</table>
</form>