php - mssql_query weird behaviour : automatically removes double-quotes around column value (and the column type is "integer")? -


i can´t find explanation behaviour (sql server 2008 + php 5.2.14)

-this piece of code works ok:

$query=' select id news..news id="727" '; $conn=mssql_connect("myddbbserver","user","password"); $idquery=mssql_query($query); $row=mssql_fetch_array($idquery); echo $row[0] 

i have id int typed column, if copy , paste query on sql server query console, following error: "the column name '727' not valid".

i have no idea why working via mssql_query, seems php_mssql driver removing double quotes... i´m sure has php_mssql driver , not other php.ini property, because if execute query using php_sqlsrv driver same error through sql server query console ("column name not valid").

any appreciated.

see set quoted_identifier in books online. when it's set on double quotes interpreted marking identifier; when it's off double quotes mark literal value. odbc , ole db set on default, different libraries can , can set explicitly if need to.

the bigger picture shouldn't embedding literal values in sql anyway. instead, should using parameterized queries (however work in particular client library) because avoids issues sql injection, quoting , data type conversion.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -