From:             cody dot stockwell at qsicorp dot com
Operating system: Red Hat 4 ES
PHP version:      4.4.7
PHP Bug Type:     ODBC related
Bug description:  odbc_execute fails with parameters

Description:
------------
The script works fine when talking to Apache(WinXP)/PHP5/DNS [SQL
Server]/MS SQL Express 2005,
but when I try to get it to run on Apache
(Linux)/PHP4/[unixODBC/FreeTDS]/MS SQL Express 2005 I get an error from
PHP.

If I place variables into the odbc_prepare() statement directly it works
fine, but for some reason refuses to replace the '?' parameter in
odbc_execute(). Obviously that would negate the security advantage of using
odbc_prepare().

So it appears to be a bug in PHP4, but unfortunately the boss is hesitant
to install PHP5 or any new version for fear of breaking everything.

Reproduce code:
---------------
<?php
$dsn = "SQLExpress";
$dbuser = "sa";
$dbpass = "mypass";
$dbname = "mydb";

$connect = odbc_connect($dsn, $dbuser, $dbpass);
odbc_exec($connect, "use " . $dbname) or die("Failed to connect to
database.");

$query = odbc_prepare($connect, "SELECT FIRST_NAME, MIDDLE_INITIAL,
LAST_NAME FROM mytable WHERE LAST_NAME = ?");
odbc_execute($query, array("Smith"));

echo odbc_result_all($query);
?>


Expected result:
----------------
FIRST_NAME      MIDDLE_INITIAL  LAST_NAME
Joseph  C       Smith
Travis  M       Smith
2

Actual result:
--------------
Warning: odbc_execute(): SQL error: <&#65533;tH&#65533;
I&#65533;&#65533;5, SQL state 00000 in SQLExecute in
/var/www/html/v_contact.php on line 11


-- 
Edit bug report at http://bugs.php.net/?id=41639&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=41639&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=41639&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=41639&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=41639&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=41639&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=41639&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=41639&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=41639&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=41639&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=41639&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=41639&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=41639&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=41639&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=41639&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=41639&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=41639&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=41639&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=41639&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=41639&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=41639&r=mysqlcfg

Reply via email to