Jump to content

guestBook


Bickey

Recommended Posts

I'm saving customer comments in an MYSQL. But the when I use mysql_real_escape_string() to filter the input data it's causing wired signs when it's displayed in the guest book. (E.g. whenever there is a ' sign, the output is \').

 

Is it safe to have a guest book without mysql_real_escape_string( or please suggest how should I go about creating this guest book on my website.

 

Thanks.

Bickey.

Link to comment
Share on other sites

If stripslashes() is necessary, the problem is occurring when the data is inserted. You probably have magic_quotes_gpc() on in your php.ini and don't check for it before escaping the data for insert. You should set magic_quotes_gpc() to Off if possible.

 

If you can't, and/or you want the code to be as portable as possible, use an escaping sequence that checks for magic_quotes_gpc(), and if on, applies stripslashes() before escaping the data.

 

if( get_magic_quotes_gpc() ) {
     $data = mysql_real_escape_string(stripslashes($_POST['data']));
} else {
     $data = mysql_real_escape_string($_POST['data']);
}

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.