Re: PHP and Microsoft SQL 7

From: Date: Tue, 10 Oct 2000 13:40:46 +0000
Subject: Re: PHP and Microsoft SQL 7
Groups: php.general 
Request: Send a blank email to php-general+get-19341@lists.php.net to get a copy of this message
Hi Jari, mssql_query takes two parameters; a query sting and a link identifier. You are trying to use the function as printf() and that will not work. suo sshoul do it like this: mssql_query("insert into news values(NULL,'$ar-$maned-$dag','$tid','$head','$content)", $conn) or die("Invalid Query"); or you could build the query string and call mssql_query($strSQL, $conn); $conn shoul have the value of a vaild connection id obtaind with $conn = mssql_connect(...); - Frank > > >I am trying to make an insert into a SQL database via a html form. >It is for a newspage on our intranet. >I think I have got everything working except the insert: > >mssql_query("insert into news >values(NULL,'%s-%s-%s','%s','%s','%s')", >$ar,$manad,$dag,$tid,$head,$content) or die("Invalid Query"); > >I get the following errormessage: >Warning: Wrong parameter count for mssql_query() in c: >\apache\htdocs\news\newsin.php on line 10 >Invalid Query > >I have tried to use NULL, 0 and nothing at all for the first field. >The $head and $content is passed from the form I use. > >The fields in the database is as follows: >id int (unique autoincrement identifier ) >date varchar ( the date of the posting yyyy-mm-dd) >time varchar ( the time of the posting hh:mm:ss ) >head varchar ( the head of the posting ) >content varchar ( the content of the posting ) > >I generate the time and date in the script since I don't know how to >get the SQL to generate it in the format I want. >In MySQL I could use currentdate() and currenttime(), but since I have >to use MSSQL... > > >Jari Ivanoff >jari.ivanoff@telia.com >+46-(0)70-3142556 > > >-- >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 (#19341) next »