Click to See Complete Forum and Search --> : Question about forms and post data:


necoris
03-09-2004, 05:31 PM
I was wondering if when you post some data through a textarea, does the server automatically add \ before any special character? I left the data raw and haven't used htmlspecialchars, but I am encountering errors with this.

Thanks for any help in advance.

Jona
03-09-2004, 06:04 PM
Originally posted by necoris
I was wondering if when you post some data through a textarea, does the server automatically add \ before any special character?

Yes, PHP will automatically escape quotes. You can remove the backslashes by using stripslashes() (http://us2.php.net/manual/en/function.stripslashes.php). You might also want to look over the general string (http://us3.php.net/types.string) information of PHP.

[J]ona

necoris
03-09-2004, 06:07 PM
Thanks bro. I also fixed some grammar issues in the update query.

It used to be:
$sql = "UPDATE table SET data=$data, data=$data WHERE id=$id";

I changed it to:
$sql = "UPDATE table SET data=\"$data\", data=\"$data\" WHERE id=\"$id\"";

That fixed the problem, but I don't know why...

Oh well.

Thanks for the other information dood, I will get right on it.

Later,
Dustin

Jona
03-09-2004, 06:37 PM
It's because you can't have quotes in quotes. That's always been the way it's been, and it probably always will be the way it will be or will have been, otherwise it'd probably not have been what it was to be from being what it wasn't. :p

[J]ona

necoris
03-09-2004, 07:19 PM
But notice how I didn't have quotes inside quotes in the previous syntax...

Jona
03-09-2004, 09:50 PM
Originally posted by necoris
But notice how I didn't have quotes inside quotes in the previous syntax...

Well you need those quotes to send the data to MySQL, otherwise it doesn't understand the values as strings.

[J]ona

necoris
03-09-2004, 10:16 PM
Well that makes it sound better... ;) Thank you for helping me. I'm surprised people actually do with programming. Hey, there's somethin for everyone, right?

Later,
Dustin