SQL Syntax error

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
janey
Forum Newbie
Posts: 13
Joined: Sat Nov 26, 2005 6:48 am
Location: stoke

SQL Syntax error

Post by janey »

i keep getting this error message:
Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft JET Database Engine
Description: Syntax error in INSERT INTO statement.' in c:\Inetpub\wwwroot\Assignment\orderconf.php:59 Stack trace: #0 c:\Inetpub\wwwroot\Assignment\orderconf.php(59): com->Execute('INSERT INTO T_o...') #1 {main} thrown in c:\Inetpub\wwwroot\Assignment\orderconf.php on line 59
this is the code to it:

Code: Select all

$adoCon->Execute
	("INSERT INTO T_order(SesId, Harrier, SixNut, Mount, Nut, Seal312a, Tracking, Wing, Turbine, Injection, Seal, UserId) VALUES ('$Session', $Harrier, $SixNut, $Mount, $Nut, $Seal312, $Track, $Wing, $Turb, $Injection, $Seal, '$User');");
can anyone help?
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

one thing i see of the bat is you only put the quotes around $Session and not any of the other values.
janey
Forum Newbie
Posts: 13
Joined: Sat Nov 26, 2005 6:48 am
Location: stoke

Post by janey »

shiznatix wrote:one thing i see of the bat is you only put the quotes around $Session and not any of the other values.
the others are numbers so they shouldnt need the quotes?

ive tested it in access and it works but it wont work if you enter it via php?
User avatar
AKA Panama Jack
Forum Regular
Posts: 878
Joined: Mon Nov 14, 2005 4:21 pm

Post by AKA Panama Jack »

Try dropping the ; in the query (yes that can mess it up in php even though you can use it command line).
janey
Forum Newbie
Posts: 13
Joined: Sat Nov 26, 2005 6:48 am
Location: stoke

Post by janey »

ive just solved it... i needed to set a default value of 0 and not "" as their number fields!

Thanks for your help everyone!
Post Reply