Jump to content

[SOLVED] special characters


timmah1

Recommended Posts

I'm trying to allow the users to be able to write their own description of things.

The problem is, if they put ' or ", it don't go into the database.

 

I have this

$hint = mysql_real_escape_string($_POST['hint'][$i]);
$hint = addslashes($_POST['hint'][$i]);

 

but it's inserting the ' or " or anything after those characters.

 

How can I get these inserted?

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/139213-solved-special-characters/
Share on other sites

ok, I'm sorry, it is inserting into the database, but when it's retrieved into the text box, it don't show correctly in the text box.

 

Right now, I have this in the database

Order tonight\'s special

 

But when it's pulled back out into the text box, it only shows

Order tonight

 

How can I show it correctly?

 

I tried this

$hint = stripslashes($a[hint]);

 

Don't use mysql_real_escape_string() AND addslashes().  Use the former.

 

Why not? just wondering...

 

<?php
echo mysql_real_escape_string(addslashes("Some random stuff ' "));
?>
OUTPUT:
Some random stuff \\\'

 

It completely wrecks your backslashes by using both of them.

Don't use mysql_real_escape_string() AND addslashes().  Use the former.

 

Why not? just wondering...

 

<?php
echo mysql_real_escape_string(addslashes("Some random stuff ' "));
?>
OUTPUT:
Some random stuff \\\'

 

It completely wrecks your backslashes by using both of them.

 

Thanks!

ok, I'm sorry, it is inserting into the database, but when it's retrieved into the text box, it don't show correctly in the text box.

 

Right now, I have this in the database

Order tonight\'s special

 

But when it's pulled back out into the text box, it only shows

Order tonight

 

How can I show it correctly?

 

I tried this

$hint = stripslashes($a[hint]);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.