TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   i keep getting unknown error by mysql (http://www.talkphp.com/absolute-beginners/2272-i-keep-getting-unknown-error-mysql.html)

sarmenhb 02-17-2008 10:30 PM

i keep getting unknown error by mysql
 
anyone see anything wrong in this query?

this is the error im getting:

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( null, 'date', '127.0.0.1', 'k', 'Open', 'Bug', 'Urgent'' at line 1


Code:

$save = mysql_query("INSERT INTO tbl_issues(id,date,ip,domain,status,type,priority,module,title,path,desc) VALUES(

null,
'date',
'$ip',
'".$_POST['txt_domain']."',
'".$_POST['drop_status']."',
'".$_POST['drop_type']."',
'".$_POST['drop_priority']."',
'".$_POST['drop_module']."',
'".$_POST['txt_title']."',
'".$_POST['txt_path']."'
'".$_POST['txt_desc']."'") or die(mysql_error());


SOCK 02-17-2008 10:37 PM

The error message gives you a big clue; desc is a reserved word.

sarmenhb 02-17-2008 11:33 PM

Quote:

Originally Posted by SOCK (Post 10951)
The error message gives you a big clue; desc is a reserved word.

lol, thanks i didnt know that.

CoryMathews 02-18-2008 01:34 AM

i did the same thing a while back. no worries.

Kalle 02-18-2008 02:25 PM

Another good reason to always use `-quotes on row names ;)

SOCK 02-18-2008 02:28 PM

Quote:

Originally Posted by Kalle (Post 10985)
Another good reason to always use `-quotes on row names ;)

... or another good reason to create thoughtful, non reserved table and column names. I agree with using `backticks` to differentiate column names from data, but it shouldn't be used as a workaround, IMHO. That's the problem with phpMyAdmin, they always use `backticks`, and when users try to use the same column names in their scripts, it always fails.


All times are GMT. The time now is 04:47 PM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0