budimir 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. Quote Link to comment https://forums.phpfreaks.com/topic/134538-solved-strange-mssql_query-error/ Share on other sites More sharing options...
rhodesa 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 Quote Link to comment https://forums.phpfreaks.com/topic/134538-solved-strange-mssql_query-error/#findComment-700549 Share on other sites More sharing options...
budimir 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 Quote Link to comment https://forums.phpfreaks.com/topic/134538-solved-strange-mssql_query-error/#findComment-700563 Share on other sites More sharing options...
budimir 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 Quote Link to comment https://forums.phpfreaks.com/topic/134538-solved-strange-mssql_query-error/#findComment-700588 Share on other sites More sharing options...
rhodesa 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 Quote Link to comment https://forums.phpfreaks.com/topic/134538-solved-strange-mssql_query-error/#findComment-700709 Share on other sites More sharing options...
budimir 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. Quote Link to comment https://forums.phpfreaks.com/topic/134538-solved-strange-mssql_query-error/#findComment-700794 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.