Jump to content

Archived

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

budimir

[SOLVED] Strange mssql_query() error!?

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.

Share this post


Link to post
Share on other sites

Check the variable $OvlasteniServis as it's empty. You can see the generated SQL has no table name in it

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

the - in the data should be fine...it's the column named 'E-mail' that is the problem

Share this post


Link to post
Share on other sites

Thanks a lot rhodesa. That helped.

 

Name of the table also contained '-'. After I removed it, it was OK.

 

Again, thanks a lot.

Share this post


Link to post
Share on other sites

×
×
  • 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.