I constructed my xml file with javascript and I show it correctly with an alert like this :
<Voitures>
<voiture par1="4" par2="1" par3="0"/>
<voiture par1="3" par2="0" par3="0"/>
</Voitures>
But the problem is when I send it with ajax to a php file I obtain this result :
<Voitures>
<voiture par1=\"4\" par2=\"1\" par3=\"0\"/>
<voiture par1=\"3\" par2=\"0\" par3=\"0\"/>
</Voitures>
Thank you
Your PHP configuration has magic quotes enabled, which is a deprecated setting that nobody should be using anymore. It has been removed in PHP 5.4. Disable it now, or you risk writing code that will behave incorrectly when you upgrade to PHP 5.4.
If that's not possible, use stripslashes()
on the value prior to doing anything else with it. Only do this if you really cannot disable magic quotes. Developing PHP software with magic quotes enabled is a very, very bad idea.
If you're trying to write good code and be future-proof, put this as the top of every file, or some common include file that gets used everywhere:
if (get_magic_quotes_gpc()) {
trigger_error("Magic quotes are enabled; please disable them.", E_USER_ERROR);
}
This will make your application simply refuse to run if magic quotes are enabled.
If you have the option, ship a .htaccess
file with your application that contains this:
php_flag magic_quotes_gpc Off
This will, if possible, disable magic quotes for your entire application when it is depolyed on Apache. If the Apache configuration does not permit php_flag
directives in .htaccess
files then this will cause an HTTP 500 error, which is miles better than letting your application run with magic quotes enabled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With