#48238 [NEW]: pg_escape_string() output should be in E'...', not '...'
| From: | thuejk at gmail dot com | Date: | Mon, 11 May 2009 19:49:16 +0000 |
| Subject: | #48238 [NEW]: pg_escape_string() output should be in E'...', not '...' | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-2236@lists.php.net to get a copy of this message | ||
From: thuejk at gmail dot com
Operating system: All
PHP version: Irrelevant
PHP Bug Type: Documentation problem
Bug description: pg_escape_string() output should be in E'...', not '...'
Description:
------------
On http://dk.php.net/pg_escape_string you write
// Escape the text data
$escaped = pg_escape_string($data);
// Insert it into the database
pg_query("INSERT INTO correspondence (name, data) VALUES ('My letter',
'{$escaped}')");
However, on a recent version on postgresql this will produce warnings (in
the postgresql log), for example if $data contains backslashes. As they
write at
http://www.postgresql.org/docs/8.3/interactive/runtime-config-compatible.html
:
escape_string_warning (boolean)
When on, a warning is issued if a backslash (\) appears in an ordinary
string literal ('...' syntax) and standard_conforming_strings is off. The
default is on.
Applications that wish to use backslash as escape should be modified
to use escape string syntax (E'...'), because the default behavior of
ordinary strings will change in a future release for SQL compatibility.
So obviously the PHP manual should be changed to use the future-proof
E'{$escaped}' instead of '{$escaped}'.
--
Edit bug report at http://bugs.php.net/?id=48238&edit=1
--
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48238&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48238&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48238&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=48238&r=fixedcvs
Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48238&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=48238&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=48238&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=48238&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=48238&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=48238&r=support
Expected behavior: http://bugs.php.net/fix.php?id=48238&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=48238&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=48238&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=48238&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48238&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=48238&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=48238&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=48238&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=48238&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=48238&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=48238&r=mysqlcfg