Jump to content

[SOLVED] Strange mssql_query() error!?


budimir

Recommended Posts

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 comment
https://forums.phpfreaks.com/topic/134538-solved-strange-mssql_query-error/
Share on other sites

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.