From: vinny at xs4all dot nl Operating system: winxp sp2 PHP version: 5.1.1 PHP Bug Type: PostgreSQL related Bug description: pg_query_params fails to escape NULL in byta fields
Description: ------------ pg_query_params() stops processing binary 'bytea' field data at hex '00'. Reproduce code: --------------- <?php /** create a PostgreSQL database (I used 8.1) with a table that has a 'bytea' field. Use pg_query_params to insert binary data from a JPG image into the bytea field, something like: */ pg_query_params("INSERT INTO tabel (byteafield) values ($1)", file_get_contents('file.jpg')); ?> Expected result: ---------------- The image should be stored in the database completely. Actual result: -------------- Only the first four bytes of the JPG data make it into the database. JPG data starts with: hex FF D8 FF E0 00 10 4A 46 49 Apparently pg_query_params stops processing the content at '00' which I guess is because PHP thinks it is at 'EOF'. If you insert the data with a normal pg_query call and using pg_escape_bytea() on the JPG data then everything works just fine and the image is stored properly. -- Edit bug report at http://bugs.php.net/?id=35800&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=35800&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=35800&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=35800&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=35800&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=35800&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=35800&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=35800&r=needscript Try newer version: http://bugs.php.net/fix.php?id=35800&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=35800&r=support Expected behavior: http://bugs.php.net/fix.php?id=35800&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=35800&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=35800&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=35800&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=35800&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=35800&r=dst IIS Stability: http://bugs.php.net/fix.php?id=35800&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=35800&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=35800&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=35800&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=35800&r=mysqlcfg