mysql insert statement
Posted: Wed Jun 22, 2005 11:09 pm
Hi all, I'm having trouble inserting data into a table in my mysql database. I've ben trying for over an hour to get it to work and have no idea why it isn't (I'm fairly new to PHP and SQL). Here's my code:
The problem is with the $query I think because the page parses fine.. I just get a MySQL error.
This is what I get from mysql_error():
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 'desc, filepath, thumbpath) VALUES('', 'third inr comic', 'hope t
Thank you all for having a look, it's really important I get this working (it's for a major project at school) and I am quite stumped at this point.
- Drummer87
Code: Select all
<?php
include ( "dbconnect.php" );
if ( ($_FILES['fupload']['type'] == "image/gif") OR ($_FILES['fupload']['type'] == "image/png") OR ($_FILES['fupload']['type'] == "image/jpeg") ) {
$source = $_FILES['fupload']['tmp_name'];
$target = "photos/".$_FILES['fupload']['name'];
$targetthumb = "photos/thumb-".$_FILES['fupload']['name'];
move_uploaded_file( $source, $target );
print "<b>Upload successful</b><br>";
print "<a href=\"admin.php\">Return</a>";
} else {
print "Upload failed, please try again";
}
$title = $_POST[title];
$desc = $_POST[desc];
print $title."<br>";
print $desc."<br>";
print $target."<br>";
print $targetthumb."<br><br>";
$query = "INSERT INTO entries (ID, title, desc, filepath, thumbpath) VALUES('', '$title', '$desc', '$target', '$targetthumb')";
print $query."<br><br>";
mysql_query( $query ) or die ( mysql_error() );
mysql_close( $link );
?>This is what I get from mysql_error():
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 'desc, filepath, thumbpath) VALUES('', 'third inr comic', 'hope t
Thank you all for having a look, it's really important I get this working (it's for a major project at school) and I am quite stumped at this point.
- Drummer87