Page 1 of 1

can't find sql error =(

Posted: Fri Feb 23, 2007 6:37 pm
by psychotomus
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 ) VALUES ( 'Test', 'testers', 'description for test' ' at line 4

anyone know where its at?

Code: Select all

$cat = $_POST['select'];
		$name = $_POST['textForumName'];
		$desc = $_POST['textForumDesc'];
		
		//get last forum order
		$result = mysql_query("SELECT forum_order FROM forums WHERE cat='$cat' ORDER BY forum_order DESC");
		$forum_info = mysql_fetch_object($result);
		
		mysql_query("INSERT INTO forums (
				cat,
				name,
				desc
				)
				VALUES (
				'$cat',
				'$name',
				'$desc'
				)") or die(mysql_error());

Posted: Fri Feb 23, 2007 6:38 pm
by psychotomus
nevermind =) desc is reserved word in sql =)

Posted: Sat Feb 24, 2007 3:29 am
by mikeq
as you've discovered you shouldn't use reserved words in your table definitions. And there is no reason not to use full words as column name such 'description'.

However if you must, you can enclose the field name in back ticks `

Code: Select all

INSERT INTO forums (cat, name, `desc`)
VALUES
('$cat','$name','$desc')