XILO Community Forum

Support 0845 034 6444 • Sales 0800 084 2421

  (#1 (permalink)) Old
Reseller
travellinglad is on a distinguished road
 
Posts: 81
Join Date: Dec 2005
Default PHP Magic quotes - 15/02/2007, 6:21 PM

What does anyone know about Magic quotes within PHP?

If I have data which includes a ' like Cote d'Azur it transforms it to Cote d\'Azur.

I've heard of different ways to solve this problem:

Adding additional code into the PHP script
or Altering the .htaccess file.

Any ideas which is the best route to take and is the code different for every scenario?
Reply With Quote
  (#2 (permalink)) Old
Techie & Moderator
Kieran is on a distinguished road
 
Kieran's Avatar
 
Posts: 769
Join Date: Apr 2006
Location: Swindon, UK
Default Re: PHP Magic quotes - 15/02/2007, 7:07 PM

There are functions within php to manipulate this kind of data.

You may like to look at
addslashes()
stripslashes()

Magic quotes are the spawn of satan in my humble opinion. That aside turning them on can cause problems for applications that are written for them to be off.
Reply With Quote
  (#3 (permalink)) Old
Reseller
travellinglad is on a distinguished road
 
Posts: 81
Join Date: Dec 2005
Thumbs up Re: PHP Magic quotes - 16/02/2007, 3:51 PM

Is this something I could myself or would I be best paying for someone to change the script.

There's two occassions when the \' appears, in the meta tag, i.e.

PHP Code:
<title><? echo $field;?> travel guide</title>
When the $field is Cote d'Azur I get the slash appear

Also when I enter the
PHP Code:
<? echo $field;?>
within the content it comes with a slash too.

Do I simply add stripslashes() to the script?

Thanks for the advice.
Reply With Quote
  (#4 (permalink)) Old
Techie & Moderator
Kieran is on a distinguished road
 
Kieran's Avatar
 
Posts: 769
Join Date: Apr 2006
Location: Swindon, UK
Default Re: PHP Magic quotes - 16/02/2007, 4:32 PM

By the sounds of thigns you'd want
Code:
stripslashes($field)
For every instance of the field variable exhibiting the problem. No need to spend money
Reply With Quote
  (#5 (permalink)) Old
Reseller
travellinglad is on a distinguished road
 
Posts: 81
Join Date: Dec 2005
Default Re: PHP Magic quotes - 16/02/2007, 6:09 PM

Wow that easy! Thanks Keiran, I owe you a pint!

So I have this snippet of code

PHP Code:
<title><? echo $field;?> travel guide</title>
Whereabouts do I put the stripslashes($field) within the code? I tried before the < title > and within it.

Thanks!!
Reply With Quote
  (#6 (permalink)) Old
Reseller
travellinglad is on a distinguished road
 
Posts: 81
Join Date: Dec 2005
Default Re: PHP Magic quotes - 16/02/2007, 6:21 PM

Ignore the post - just sorted it!!! Excellent, I've been wanting to get to the bottom of that problem for months!

Thanks Keiran!
Reply With Quote
  (#7 (permalink)) Old
Techie & Moderator
Kieran is on a distinguished road
 
Kieran's Avatar
 
Posts: 769
Join Date: Apr 2006
Location: Swindon, UK
Default Re: PHP Magic quotes - 16/02/2007, 7:02 PM

Not a problem, glad its fixed
Reply With Quote
  (#8 (permalink)) Old
Reseller
travellinglad is on a distinguished road
 
Posts: 81
Join Date: Dec 2005
Default Re: PHP Magic quotes - 20/02/2007, 1:36 PM

I just wanted to publically thank Kieran for all his help - it was solved, but caused over problems which Kieran kindly sorted for me.

Another reason why I am glad to be with Xilo (despite my moan earlier) is this excellent forum.
Reply With Quote
  (#9 (permalink)) Old
Techie & Moderator
Kieran is on a distinguished road
 
Kieran's Avatar
 
Posts: 769
Join Date: Apr 2006
Location: Swindon, UK
Default Re: PHP Magic quotes - 20/02/2007, 5:43 PM

Glad to have been of assistance to you. Feel free to ask if you have any other issues with scripts etc.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Disable Magic Quotes Miselph Support Queries 1 28/03/2008 2:41 PM


Powered by vBulletin | XHTML | © Copyright 2003-2008 XILO Communications Ltd. All rights reserved. E&OE