PDA

View Full Version : apostrophes in php


shane.carr
06-01-2006, 05:12 PM
Hi! This should be an obvious question with an easy answer. How do you echo an apostrophe without having a backslash behind it?

lavinpj1
06-01-2006, 06:28 PM
echo ("this wasn't working");

shane.carr
06-08-2006, 08:15 PM
echo ("this wasn't working");
How do you echo an apostrophe without having a backslash behind it?

Sorry lavinpj1, but that didn't answer my question. But, I found another way:


stripslashes($_POST['helloworld'])


Thanks anyway!

Kid Charming
06-08-2006, 08:57 PM
The question was probably misunderstood. When echoing, you can use single or double-quotes around the string to quote. If you use single-quotes, apostrophes have to be escaped with a backslash, or you'll get an error.

What you're running into is the magic_quotes_gpc directive, which, when turned on in your php.ini, automatically escapes quotes that come from POST/GET/COOKIE operations. It does this as a security measure to help protect you from SQL injection attacks when you insert into a database.

GJay
06-08-2006, 10:17 PM
except more often does more harm than good, and is as such being scrapped for PHP6.

Kid Charming
06-08-2006, 10:23 PM
except more often does more harm than good, and is as such being scrapped for PHP6.

That is fabulous news. I hate magic quotes. :thumbsup:

shane.carr
06-14-2006, 02:07 AM
What you're running into is the magic_quotes_gpc directive, which, when turned on in your php.ini, automatically escapes quotes that come from POST/GET/COOKIE operations.

Oops! I guess I forgot to tell you that the variables were from $_POST. But, anyways, problem solved!