PHP 4.0 Bug #2976: odbc_execute miss-use SQLBindParameter

From: Date: Wed, 15 Dec 1999 03:40:30 +0000
Subject: PHP 4.0 Bug #2976: odbc_execute miss-use SQLBindParameter
Groups: php.dev 
Request: Send a blank email to php-dev+get-13702@lists.php.net to get a copy of this message
From: JimmyLee@openpath.com.tw Operating system: WinNT 4.0 PHP version: 4.0 Beta 3 PHP Bug Type: ODBC related Bug description: odbc_execute miss-use SQLBindParameter while use odbc prepare, if query statment owns one more variables, odbc execute will result wrong parameter binding if these variables are not the same type. For example, in SQL Server 7, establish a table 'TABLE1' with two columns: name:char(10), age:int, then try to insert some records as follow : <br> $conn = odbc_connect("SQL_7_DSN", "", "", SQL_CUR_DEFAULT) or die("Connect error\n"); $stmt = odbc_prepare($conn, "insert into TABLE1 (name,age) values(?,?)") or die("Prepare error\n"); #odbc_exec($conn, "insert into TABLE1 (name,age) values('abc',1)"); # odbc_exec works fine without error for ($i=0; $i <= 10; $i++) { odbc_execute($stmt, array("abc".$i, $i)); } odbc_close($conn); But, if change "insert into TABLE1 (name,age) values (?,?)" to "insert into TABLE1 (age,name) values (?,?)" and change odbc_execute($stmt, array("abc".$i, $i)) to odbc_execute($stmt, array($i, "abc".$i)), everything works fine in SQL Server. It seems odbc_execute did not bind right parameter to right variables. I suggest add some function like odbc_bindParameter(...) to set suitable type. BTW, take MS Access as DSN, which one in the above will not works :(

« previous php.dev (#13702) next »