#18673 [Opn->Bgs]: PHP under Linux/Apache preserve the ' coming from a DB and hide itunder Windows

From: Date: Wed, 31 Jul 2002 15:30:14 +0000
Subject: #18673 [Opn->Bgs]: PHP under Linux/Apache preserve the ' coming from a DB and hide itunder Windows
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-15692@lists.php.net to get a copy of this message
ID: 18673 Updated by: rasmus@php.net Reported By: papejack@hotmail.com -Status: Open +Status: Bogus Bug Type: Output Control Operating System: Win98SE/Linux PHP Version: 4.2.2 New Comment: Set the magic_quotes_* initialization variables in your php.ini file to be the same thing on both Linux and Windows. Previous Comments: ------------------------------------------------------------------------ [2002-07-31 11:28:08] papejack@hotmail.com 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 this bug report at http://bugs.php.net/?id=18673&edit=1

« previous php.bugs (#15692) next »