#18673 [NEW]: PHP under Linux/Apache preserve the ' coming from a DB and hide itunder Windows
| From: | papejack at hotmail dot com | Date: | Wed, 31 Jul 2002 15:28:08 +0000 |
| Subject: | #18673 [NEW]: PHP under Linux/Apache preserve the ' coming from a DB and hide itunder Windows | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-15691@lists.php.net to get a copy of this message | ||
From: papejack@hotmail.com
Operating system: Win98SE/Linux
PHP version: 4.2.2
PHP Bug Type: Output Control
Bug description: PHP under Linux/Apache preserve the ' coming from a DB and hide itunder
Windows
script example:
<?php
$SQL = "INSERT INTO Table SET Field = '";
$Recordset = mysql_query("SELECT Field FROM Table", $Link);
//we assume that the string in Field contains a caracter
//that needs a \
while($Record = mysql_fetch_array($Recordset))
{
//This string contains \ under Linux/apache
//and works
mysql_query($SQL.$Record["Field"]."'", $Link);
//This string doesn't have \ under Windows
//and doesn't works (produce an error)
mysql_query($SQL.$Record["Field"]."'", $Link);
}
The problem can be fix by adding:
...
addslashes(stripslashes($Record["Field"]))
...
So, under Windows, we simply stripslashes() nothing (because there is no
\) and under Linux/Apache we stripslashes() all characters that needs to
be slashed.
Finally, in the 2 cases, we need to addslashes(). (if we don't uses
stripslashes(), we will double the \ under Linux/Apache).
Jacques Bérard
papejack@hotmail.com
--
Edit bug report at http://bugs.php.net/?id=18673&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=18673&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=18673&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=18673&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=18673&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=18673&r=support
Expected behavior: http://bugs.php.net/fix.php?id=18673&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=18673&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=18673&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=18673&r=globals