> PHP / MySQL
>
>
>
> I'm using PHP to retrieve user input and store it in MySQL. PHP's
> addslashes function is used on data going into the database and PHP's
> stripslashes function is being used on data coming from the database.
This
> is allowing me to store and retrieve data with no problems, but it's
causing
> problems when trying to sort data. In particular, data with double or
> single quotes is getting escaped, which changes it's position in the sort.
>
>
Sounds like you are escaping twice. If you have magic_quotes_gpc enabled
then your data is already being escaped when it's submitted. Most likely
this is your problem.
magic_quotes_gpc is a bad hack and is actually disabled in newer releases.
However, if you're a noob, you might want to leave it on. :-) The problem is
that when magic_quotes_gpc adds slashes to escape quotes and then you
explicitly escape them again with add_slashes() you end up with all quotes
escaped twice.
Now your asking: "why then is there only one slash in the database?"
Simple:
try this:
INSERT INTO sometable VALUES('Ed\'s','\'Pizza\'');
and then...
SELECT * FROM sometable;
+------+----------+
| name | what |
+------+----------+
| Ed's | 'Pizza' |
+------+----------+
The slashes never actually get inserted into the table so there is no need
to call strip_slashes() on the results either. :-)
Jim Grill
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]