Jump to content

Recommended Posts

I have spent many an hour trying to understand this apostophe problem and escape strings, etc. etc. and thought I had it figured out - well, I guess I didn't.

 

I changed hosting servers yesterday, and copied everything to the new server - no code was changed but now I have the same problem as I did before.

 

Whenever someone places an apostrophe in an form input, the output shows a \ before the apostrophe.

 

So what could possibly be different in PHP or MySQL that I can change so it works like it did on the old server. I know this is a broad question but I just don't get what could be different.

 

I don't understand this escape crap, htmlentities, and addslashes, and whatever else to start with and spent litterly hours on end getting it to work, just to have it fall apart on another server.

 

 

Any help is appreciated, I have to cut this short as this forum is acting up as well and is bouncing all over the place.

Link to comment
https://forums.phpfreaks.com/topic/196940-apostrophes-again/
Share on other sites

[sarcasm]Oh no, not more time wasted by a php feature that was supposed to be a lazy what short cut to "help a few beginners blissfully and unknowingly write better (more secure) code."[/sarcasm]

 

What is your current form processing code and the code that is retrieving the data from the database?

 

What does a phpinfo() statement show for the magic_quotes_gpc and magic_quotes_runtime settings?

 

 

Link to comment
https://forums.phpfreaks.com/topic/196940-apostrophes-again/#findComment-1033913
Share on other sites

Not 100% sure what you are asking here.

 

"What is your current form processing code and the code that is retrieving the data from the database?"

 

But when code is imput I use mysql_real_escape_string($var).

 

When I view it I use something like this - stripslashes(htmlentities($var],ENT_QUOTES))

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/196940-apostrophes-again/#findComment-1033923
Share on other sites

What you should really do is incorporate this logic if you do not understand:

$string = "I'm full of nonsense and things!"

if(get_magic_quotes_gpc()):
     stripslashes($string);
} 

$string = mysql_real_escape_string($string);
//Continue to send to DB

Link to comment
https://forums.phpfreaks.com/topic/196940-apostrophes-again/#findComment-1035059
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.