#32750 [Opn]: pg_escape_string removes some backslashes

From: Date: Thu, 21 Apr 2005 21:31:11 +0000
Subject: #32750 [Opn]: pg_escape_string removes some backslashes
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-78021@lists.php.net to get a copy of this message
ID: 32750 User updated by: master-bx at users dot sourceforge dot net Reported By: master-bx at users dot sourceforge dot net Status: Open Bug Type: PostgreSQL related Operating System: Windows XP SP2 PHP Version: 5.0.4 New Comment: The bug can be closed, my mistake. variable must be first set to static an then defined. that caused the error. nevertheless thanks for help. Previous Comments: ------------------------------------------------------------------------ [2005-04-21 20:22:47] master-bx at users dot sourceforge dot net yes, here is my mysql testing code: <?php function sql_escape($var) { if(!isset($mq_gpc)) { $mq_gpc = ini_get('magic_quotes_gpc'); static $mq_gpc; } if(!empty($mq_gpc)) { stripslashes($var); } return <>($var); } ?> <> = mysql(i)_real_escape_string or pg_escape_string mysql works, mysqli and pg not, but i found a typo in a function that uses this one. i will go on testing ... ------------------------------------------------------------------------ [2005-04-21 14:38:12] sniper@php.net Have you read this manual page very carefully: http://www.php.net/mysql_real_escape_string Especially the part about magic_quotes..(the example too) ------------------------------------------------------------------------ [2005-04-20 23:16:14] master-bx at users dot sourceforge dot net Parse error: syntax error, unexpected $end in ***\Apache2\htdocs\test.php on line 6 So my example has been wrong, sorry. Tried it with '\ \\ \\\\' and got the following: string(6) '\ \ \\' string(10) '\\ \\ \\\\' So it does well, but ... to better describe my problem: mysql_real_escape_string does it another way, because it handles POST-data correct for database-storage. pg_escape_string and mysqli_real_escape_string are cutting some \ and i don't get the data stored like the input cames from POST. do you understand it now or need a larger example? ------------------------------------------------------------------------ [2005-04-20 17:06:09] sniper@php.net Please paste the exact output of this script: <?php $var = '\ \\ \\\'; var_dump($var); $test = pg_escape_string($var); var_dump($test); ?> ------------------------------------------------------------------------ [2005-04-20 11:36:45] master-bx at users dot sourceforge dot net $var outputs \ \\ \\\ before and after it, and $test doesn't get an extra \ in most of my tests. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/32750 -- Edit this bug report at http://bugs.php.net/?id=32750&edit=1

« previous php.bugs (#78021) next »