riscphree
05-22-2007, 04:03 PM
I get this error:
Could not add the item 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 'Title, picture, this is the mini desc, http://google.com, test-p. The query was INSERT INTO media (id, title, type, minidesc, url, thumb, datetime, type2) VALUES (0, My Title, picture, this is the mini desc, http://test.com, test-post.jpg, NOW(), 3).
While using this insert query:
$title = $_POST['title'];
$type = $_POST['type'];
$minidesc = $_POST['minidesc'];
$url = $_POST['url'];
$thumb = $_POST['thumb'];
switch($type){
case game:
$type2 = '1';
case video:
$type2 = '2';
case picture:
$type2 = '3';
}
$query = "INSERT INTO media (id, title, type, minidesc, url, thumb, datetime, type2) VALUES (0, $title, $type, $minidesc, $url, $thumb, NOW(), $type2)";
if (@mysql_query ($query)) {
print '<p>The item has been added.</p>';
} else {
print "<p>Could not add the item because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}
Not sure what is up? Any hints? Everything looks good what it is reporting in the error message, it just seems to not want to go in the database.
Could not add the item 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 'Title, picture, this is the mini desc, http://google.com, test-p. The query was INSERT INTO media (id, title, type, minidesc, url, thumb, datetime, type2) VALUES (0, My Title, picture, this is the mini desc, http://test.com, test-post.jpg, NOW(), 3).
While using this insert query:
$title = $_POST['title'];
$type = $_POST['type'];
$minidesc = $_POST['minidesc'];
$url = $_POST['url'];
$thumb = $_POST['thumb'];
switch($type){
case game:
$type2 = '1';
case video:
$type2 = '2';
case picture:
$type2 = '3';
}
$query = "INSERT INTO media (id, title, type, minidesc, url, thumb, datetime, type2) VALUES (0, $title, $type, $minidesc, $url, $thumb, NOW(), $type2)";
if (@mysql_query ($query)) {
print '<p>The item has been added.</p>';
} else {
print "<p>Could not add the item because: <b>" . mysql_error() . "</b>. The query was $query.</p>";
}
Not sure what is up? Any hints? Everything looks good what it is reporting in the error message, it just seems to not want to go in the database.
