Click to See Complete Forum and Search --> : mySQL insert statement error


scouse
06-29-2005, 05:36 AM
Hi,

I have done Insert statements many times before and never have a problem, but for some reason I've tried it this time and its coming up with an error.

I reckon I've just made a silly mistake in the syntax, but I've been staring at it for so long now that I can't find the mistake. :rolleyes:

Could someone just have a look at the following bit of code and let me know if there is something obvious which is stopping it from working:



sqlPAGE="INSERT INTO mess(FROM, TO, SUBJECT, MESSAGE, LINK, DATE, ARCHIVE) VALUES('"&strFROM&"', '"&strTO&"', '"&strSUBJECT&"', '"&strMESSAGE&"', '"&strLINK&"','"&strDATE&"', '"&strARCHIVE&"')"
objConn.Execute(sqlPAGE)




This is the error that it is generating


Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[MySQL][ODBC 3.51 Driver][mysqld-4.1.8-nt]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 'FROM, TO, SUBJECT, MESSAGE, LINK, DATE, ARCHIVE) VALUES('HOLLY', 'PHIL', '1', '1' at line 1



Any help would be appreciated.

Thanks

Phil

keerthi
06-29-2005, 06:44 AM
hi

i would suggest you not to use keywords like from,to as field names.

try to use someother fieldname instead of FROM,TO,DATE.

it would be greatfull if u if u let me know the result.

all the best,keep smiling

keats :)

scouse
06-29-2005, 07:20 AM
Cheers Keats,

You were spot on, the keywords must have been confusing it and generating the error.

I guess thats a lesson for me to use better field names.

Thanks again

Phil

keerthi
07-01-2005, 03:14 AM
Great Phil..I have a doubt in php.is there a way to popup a msgbox in php script rather going to javascript.

keep Smiling
keerthi

buntine
07-01-2005, 05:02 AM
No. PHP and ASP are alike in that they both run from the server (possible thousands of miles away from the clients Web Browser). Only a client-side language -- like JavaScript -- can popup a message box on the screen.

Regards.

search_find
07-04-2005, 01:24 PM
I suggest you can use "echo" in PhP and "Response.write" in ASP to write the SQL statement to the output page. Then you can test the statement by run in directly in the DBMS. With the message box, you can copy the statement that easily.