budimir 1 Posted November 27, 2008 Share Posted November 27, 2008 Hey guys, I'm using this query to insert data into MSSQL table $upit1 = "INSERT INTO $OvlasteniServis ([Vrsta servisa], [Grad], [Poštanski broj], [Naziv servisa], [Adresa], [Telefon], [Fax], [E-mail]) VALUES ('$da', '$grad', '$ptt', '$naziv', '$adresa', '$telefon', '$fax', '$email')"; $rezultat1 = mssql_query($upit1,$veza3) or die ("MSSQL upit nije uspio!!!"); And this is error message I'm getting: INSERT INTO (Vrsta servisa, Grad, Poštanski broj, Naziv servisa, Adresa, Telefon, Fax, E-mail) VALUES ('1', 'Krk', '51500', 'CRO - FUTURA d.o.o.', 'Slavka Nikolića 48', '051/221-441', '', 'cro-futura@ri.htnet.hr') Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near '('. (severity 15) in C:\wamp\www\erp\sql_servis.php on line 87 I'm a new to MSSQL, so if you can help or point me to some page where I could read about this, I would appreciate it. Thanks a lot. Link to post Share on other sites
rhodesa 0 Posted November 27, 2008 Share Posted November 27, 2008 Check the variable $OvlasteniServis as it's empty. You can see the generated SQL has no table name in it Link to post Share on other sites
budimir 1 Posted November 27, 2008 Author Share Posted November 27, 2008 Thanks a lot, rhodesa. I made a mistake and putted $ infront of the tbl_name. But, now I'm getting this error. INSERT INTO OvlasteniServis ([Vrsta servisa], [Grad], [Poštanski broj], [Naziv servisa], [Adresa], [Telefon], [Fax], [E-mail]) VALUES (1, 'Krk', 51500, 'CRO - FUTURA d.o.o.', 'Slavka Nikolića 48', '051/221-441', '', 'cro-futura@ri.htnet.hr') Warning: mssql_query() [function.mssql-query]: message: Invalid object name 'OvlasteniServis'. (severity 16) in C:\wamp\www\erp\sql_servis.php on line 87 Link to post Share on other sites
budimir 1 Posted November 27, 2008 Author Share Posted November 27, 2008 OK, I got that fixed. The problem was I had spaces in column names. Now the problem is the '-' sign in one of the variables. How do I force MSSQL to accept this data??? This the error I'm getting: INSERT INTO OvlasteniServis (Vrstaservisa, Grad, Postanskibroj, Nazivservisa, Adresa, Telefon, Fax, E-mail) VALUES (1, 'Krk', 51500, 'CRO - FUTURA d.o.o.', 'Slavka Nikolića 48', '051/221-441', '', 'cro-futura@ri.htnet.hr') Warning: mssql_query() [function.mssql-query]: message: Incorrect syntax near '-'. (severity 15) in C:\wamp\www\erp\sql_servis.php on line 87 Link to post Share on other sites
rhodesa 0 Posted November 28, 2008 Share Posted November 28, 2008 the - in the data should be fine...it's the column named 'E-mail' that is the problem Link to post Share on other sites
budimir 1 Posted November 28, 2008 Author Share Posted November 28, 2008 Thanks a lot rhodesa. That helped. Name of the table also contained '-'. After I removed it, it was OK. Again, thanks a lot. Link to post Share on other sites
Recommended Posts
Archived
This topic is now archived and is closed to further replies.