I'm having some problems with using addslashes($string) for preparing a text blob for
a MySQL database. The $string can have single or double quotes in it, and depending on
how I pass it on to the insert, it seems to work only for either single or double, but
not for both.
Input can be:
This is John's quote "Hello"
so I have to be able to capture both single and double and end up with:
This is John\'s quote \"Hello\"
but it seems like addslashes only handles one or the other but not both. Is this true?
Or is it because I quote the $string in my form like this:
$string = addslashes($string);
echo("
...
<input type='hidden' name='string' value=\"$string\">
...
");
the problem happens before I get to the insert command, because I can echo the $string
and see where it chops it if there are an odd number of quotes.
In the example above, I would end up with:
This is John's quote
when I check the passed parameter, it is coded:
string=This+is+John%27s+quote+
apparently because the first double quote of the <input> statement is matched to the
double quote in the string even tho it was \". If I change the input to <input
type='hidden' name='string' value=\'$string\'> then similar things happen, such as it
gets chopped at the single quote. I've played around with the input string, both
escaping it and using " vs. ' but nothing works for both.
Any suggestions?
Terry
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]