i have atextare in my form. when i fill the text are with this suppose "article's"
after submission of the page send it o databse .
when i try to retrive from tahe databse
i get
artice/'s. why i am getting / . pls any body help

Dani AI

Generated

As found (and as pointed out), those backslashes are PHP escaping single quotes before the data reaches your code. That behavior was the old "magic quotes" feature. It was deprecated and later removed; see the PHP manual for details and migration notes ().

Short-term fix: strip the automatic slashes once when you accept input, then treat/stored data as raw text. Example pattern:

if (get_magic_quotes_gpc()) {
    $text = stripslashes($_POST['your_textarea']);
} else {
    $text = $_POST['your_textarea'];
}
$display = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');

Use stripslashes() only when get_magic_quotes_gpc() returns true; see stripslashes(). Always run htmlspecialchars() before echoing into an HTML page to prevent XSS.

Long-term best practice: disable magic quotes on the server (or upgrade PHP; the feature is removed in modern PHP), stop storing escaped strings in the database, and use parameterized queries (PDO or mysqli prepared statements) so you never manually add/remove slashes for SQL. If the database already contains backslash-escaped strings, write a one-time script to read, stripslashes, and update each row—but back up the database first and test on a copy. For prepared statements and safer DB handling see the PHP docs on prepared statements (PDO prepared statements).

Recommended Answers

All 2 Replies

i have atextare in my form. when i fill the text are with this suppose "article's"
after submission of the page send it o databse .
when i try to retrive from tahe databse
i get
artice/'s. why i am getting / . pls any body help

You probably mean \, not /. *Crystal Ball Mode*: You're using PHP, and it is magically adding slashes, due to the way it's set up, resulting in slashes being added one too many times.

Or should I translate this into your language?

u probably mean \ not /
your using Php .it is magicly ading slshes, due to setup
reslting in
slash being adde eon to money times.

You probably mean \, not /. *Crystal Ball Mode*: You're using PHP, and it is magically adding slashes, due to the way it's set up, resulting in slashes being added one too many times.

Or should I translate this into your language?

u probably mean \ not /
your using Php .it is magicly ading slshes, due to setup
reslting in
slash being adde eon to money times.

yes ur right i men \ is it possible to remove that becose it looks very ugly sometimes lets 's
loooks like let\\\'s. so will u help me

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.