proctk Posted July 14, 2007 Share Posted July 14, 2007 Hi the below code is giving me this error and I cannot figure out why SQL Error: INSERT INTO albumNames (user_id, name, location, desc, createdate) VALUES('63', 'Family Tip', 'mjljo', 'ln', now()) 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, createdate) VALUES('63', 'Family Tip', 'mjljo', 'ln', now( and ideas by if(isset($_POST['create_album'])){ $location = $_POST['location']; $name = $_POST['name']; $desc = $_POST['desc']; $user_id = $_SESSION['user_id']; if(!$name){ $msg .= "You must enter an Album Name<br />"; header("location: $url?msg=$msg"); exit(); } $query_create_album = ("INSERT INTO albumNames (user_id, name, location, desc, createdate) VALUES('$user_id', '$name', '$location', '$desc', now())"); $sql = mysql_query($query_create_album)or die("SQL Error: $query_create_album<br>" . mysql_error()); $msg .= "New Photo Album has been created"; header("location: $url?msg=$msg"); exit; } ?> Link to comment https://forums.phpfreaks.com/topic/59984-solved-sql-error/ Share on other sites More sharing options...
AndyB Posted July 14, 2007 Share Posted July 14, 2007 IN is a MySQL reserved word and should not be used for fieldnames or tablenames. Use something else as the field name. http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html Link to comment https://forums.phpfreaks.com/topic/59984-solved-sql-error/#findComment-298342 Share on other sites More sharing options...
proctk Posted July 14, 2007 Author Share Posted July 14, 2007 I'm not sure what you are refering to here is the table structure albumNames CREATE TABLE `albumNames` ( `id` int(10) NOT NULL auto_increment, `user_id` int(10) NOT NULL, `name` varchar(50) NOT NULL, `location` varchar(50) NOT NULL, `desc` text NOT NULL, `createdate` date NOT NULL default '0000-00-00', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 Link to comment https://forums.phpfreaks.com/topic/59984-solved-sql-error/#findComment-298344 Share on other sites More sharing options...
metrostars Posted July 14, 2007 Share Posted July 14, 2007 IN is a MySQL reserved word and should not be used for fieldnames or tablenames. Use something else as the field name. http://dev.mysql.com/doc/refman/4.1/en/reserved-words.html In was a value he was trying to insert into the data, not a field name. Link to comment https://forums.phpfreaks.com/topic/59984-solved-sql-error/#findComment-298346 Share on other sites More sharing options...
AndyB Posted July 14, 2007 Share Posted July 14, 2007 Doh. I misread it. DESC is a reserved word. The rest of my suggestion holds true. Link to comment https://forums.phpfreaks.com/topic/59984-solved-sql-error/#findComment-298347 Share on other sites More sharing options...
proctk Posted July 14, 2007 Author Share Posted July 14, 2007 thanks, I changes the desc to an other value and all is well. thank you Link to comment https://forums.phpfreaks.com/topic/59984-solved-sql-error/#findComment-298351 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.