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
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]);

 

Link to comment
Share on other sites

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.

Link to comment
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]);

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.