Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Syntax Error

Status
Not open for further replies.

streetbmx

Programmer
Dec 6, 2001
16
0
0
US
I am using the ODBC functions in PHP. I am trying to insert data into an Access database and I am recieving this error message:

Warning: SQL error: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement., SQL state 37000 in SQLExecDirect in O:\Hosted Web Sites\brandon.sungur\brandonstyle_com\profile\sign.php on line 15

here is what my script looks like:

if (isset($submit)){
$ip = $_SERVER['REMOTE_ADDR'];
$date = date('h:ia m/d/y');
$connect = odbc_connect('database, 'user', 'pass');
$query = "INSERT INTO guestbook (id, date, name, message, ip) VALUES ('NULL', '$date', '$sn', '$message', '$ip')";
odbc_exec($connect, $query); # This is line 15
odbc_close($connect);
}

I can not figure out what the syntax error is, anyone have any ideas to solve this problem?
 
If your error is in the INSERT statement then you should test your statement in Access. You might have to eMail your $query string to yourself and see if it make sence to you with the values. I would think that your chr strings don't have quotes around them. Also I don't think that you need single quotes around the word NULL.

HTH
vb_doc@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top