I am using the following code (recommended by Kevin Yank in his php/mysql book) to keep apostrophes in my form data when entered into a mysql database.
<?php
if(get_magic_quotes_gpc())
{
function stripslashes_deep($value)
{
$value = is_array($value) ?
array_map('stripslashes_deep', $value):
stripslashes($value);
return $value;
}
$_POST=array_map('stripslashes_deep', $_POST);
$_GET=array_map('stripslashes_deep', $_GET);
$_COOKIE=array_map('stripslashes_deep', $_COOKIE);
$_REQUEST=array_map('stripslashes_deep', $_REQUEST);
}
?>
This works fine for apostrophes etc but now I have a problem with retaining carriage returns in the address fields of my form. Before adding the above code to solve the apostrophe problem I was using the following in my form
<?php echo str_replace('\\r\
', ' ',$inv_address); ?>
which of course does not solve the problem now and I simply get an extra rn between what should be lines in my address field. Before using the magic_quotes code above I tried many ways to retain new lines in my address fields and this was the only way that worked. Please can someone suggest the correct code to sue now?
Thanks