RE: [PHP] MSSQL Query syntax problem?

From: Date: Thu, 16 Nov 2000 09:03:30 +0000
Subject: RE: [PHP] MSSQL Query syntax problem?
Groups: php.general 
Request: Send a blank email to php-general+get-25658@lists.php.net to get a copy of this message
1. did you try to close $urgent with single quotes just like others are ? 2. why do you parse the date() and not using timestamp of MSSQL ? and then as an id you could set an auto_incremented column. try these.. -----Original Message----- From: Ivanoff Jari [mailto:Jari.Ivanoff@autonova.se] Sent: Thursday, November 16, 2000 5:49 PM To: Maxim Maletsky Subject: RE: [PHP] MSSQL Query syntax problem? Thanks... Well.. the problem persists... I have a form that gives all the variables except the date and time to the script. The entire script looks like this: <?php $db = mssql_connect("seanua02","www","www"); mssql_select_db("intranet",$db); $tid = date("H:i:s"); $dag = date("d"); $manad = date("m"); $ar = date("Y"); $datum = "$ar-$manad-$dag"; mssql_query("INSERT INTO tbl_news (date,time,head,content,urgent) VALUES ('$datum','$tid','$head','$content',$urgent)") or die("Invalid Query"); printf("<a href=\"form.html\">Åter till inmatningen</a> <a href=\"http://intranet\"> Till Huvudsidan</a>"); ?> I still get the error message after doing the changes. The weird part is that it works on my development machine with Apache, but not with my publications server which is a IIS 4. Even weirder is that I can run the script on my dev machine and connect to the database on the public server and it works but if I run it on the IIS server it doesn't work. Do you have any ideas? /Jari > -----Original Message----- > From: Maxim Maletsky [SMTP:maxim.maletsky@japaninc.net] > Sent: den 16 november 2000 09:33 > To: 'Ivanoff Jari'; 'PHP' > Subject: RE: [PHP] MSSQL Query syntax problem? > > you don't need that ';' at the end of your query. > additionally you could change your double quotes to single quote without > escaping them, better for eyes: > > mssql_query("INSERT INTO tbl_news (date,time,head,content,urgent) VALUES > ('$datum','$tid','$head','$content',$urgent)") or > die("Invalid > Query"); > > > Cheers, > Maxim Maletsky > > -----Original Message----- > From: Ivanoff Jari [mailto:Jari.Ivanoff@autonova.se] > Sent: Thursday, November 16, 2000 5:22 PM > To: 'PHP' > Subject: [PHP] MSSQL Query syntax problem? > > > When I run this query: > mssql_query("INSERT INTO tbl_news (date,time,head,content,urgent) VALUES > > (\"$datum\",\"$tid\",\"$head\",\"$content\",$urgent);" > ) or die("Invalid > Query"); > > I get this errormessage: > Warning: MS SQL message: Line 1: Incorrect syntax near ')'. (severity 15) > in > D:\Inetpub\intranet.autonova.se\uddevalla\news\newsin.php on line 9 > I can't see anything obvious, but then I am a newbie to this. > I have tried with and without the ; inte the sql statement. > Please help me! > > /Jari Ivanoff > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#25658) next »