<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1044033" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1044033</link>
    <description></description>
    <language>en</language>
          <item>
    <title>According to my host, it&#039;s</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/how-can-i-prevent-apostrophes-being-backslashed-out-php#comment-1242293</link>
    <description> &lt;p&gt;According to my host, it&#039;s supposed to be turned off at server level.  I&#039;m aware they had a few problems with some servers when they switched magic_quotes off by default a few months ago (it didn&#039;t switch off for all of them) but they have said (in a forum thread I read today) they&#039;ll switch it off when notified that it&#039;s still &quot;on&quot; for a server (I tried to rephrase that several ways and it always came out a mouthful).  I&#039;ll see what happens over the next few days.&lt;/p&gt;
 </description>
     <pubDate>Wed, 03 Jun 2009 00:17:37 +0000</pubDate>
 <dc:creator>Midas</dc:creator>
 <guid isPermaLink="false">comment 1242293 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>np 
It would be better if it</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/how-can-i-prevent-apostrophes-being-backslashed-out-php#comment-1242286</link>
    <description> &lt;p&gt;np &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
&lt;p&gt;It would be better if it was turned off at server level, but as long as you&#039;re sorted that&#039;s the main thing.&lt;/p&gt;
 </description>
     <pubDate>Tue, 02 Jun 2009 15:34:00 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1242286 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Greg, we&#039;ve sussed it -</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/how-can-i-prevent-apostrophes-being-backslashed-out-php#comment-1242278</link>
    <description> &lt;p&gt;Greg, we&#039;ve sussed it - magic_quotes_gpc wasn&#039;t turned off.  I&#039;ve added a line to my php.ini file to turn it off and the script now works as it should.&lt;/p&gt;
&lt;p&gt;Your advice has been very helpful, thank you.&lt;/p&gt;
 </description>
     <pubDate>Tue, 02 Jun 2009 15:26:34 +0000</pubDate>
 <dc:creator>Midas</dc:creator>
 <guid isPermaLink="false">comment 1242278 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Midas wrote:
I&#039;ve thought of</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/how-can-i-prevent-apostrophes-being-backslashed-out-php#comment-1242275</link>
    <description> &lt;p&gt;&lt;div class=&quot;quote-msg&quot;&gt;&lt;div class=&quot;quote-author&quot;&gt;&lt;em&gt;Midas&lt;/em&gt; wrote:&lt;/div&gt;I&#039;ve thought of using str_replace to remove the offending alterations.&lt;/div&gt;As I said, you need to find out why the slashes are being escaped first to know what solution to use.&lt;/p&gt;
&lt;p&gt;And always use the right tool for the job. With PHP, that can mean using a function or method that takes a lot more server resource.&lt;br /&gt;
At a guess, str_replace() probably uses more resource than stripslashes(), although I&#039;m not sure about that without research or benchmarking..&lt;/p&gt;
&lt;p&gt;Put the following in a file (preferably an empty test one and away from public)&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;get_magic_quotes_gpc&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
And tell us if it outputs a 0 or 1.&lt;/p&gt;
 </description>
     <pubDate>Tue, 02 Jun 2009 14:31:54 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1242275 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>Thank you Greg, I did mean</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/how-can-i-prevent-apostrophes-being-backslashed-out-php#comment-1242274</link>
    <description> &lt;p&gt;Thank you Greg, I did mean apostrophes and not comas (I knew at the time of writing I&#039;d used the wrong word but didn&#039;t fully twig-on).  I&#039;ve checked with my host and magic_quotes_gpc is supposed to be turned off but I&#039;m not sure it is so I&#039;m dealing with that one now.&lt;/p&gt;
&lt;p&gt;I&#039;m new to php so most of what you wrote went straight over my head but working it out will keep me busy for the rest of today.&lt;/p&gt;
&lt;p&gt;I&#039;ve thought of using str_replace to remove the offending alterations.  I&#039;ll wait until I know that magic_quotes_gpc is definitely off before I alter the script.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;On a slight side note. Why do you set $adcode to $_POST[&#039;adcode&#039;], then set $code to $adcode?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I adapted the script from another one.  When adapting it, I thought about doing as you suggest but changed my mind; I&#039;ll change it today.&lt;/p&gt;
 </description>
     <pubDate>Tue, 02 Jun 2009 14:06:33 +0000</pubDate>
 <dc:creator>Midas</dc:creator>
 <guid isPermaLink="false">comment 1242274 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title>I presume by &quot;comas&quot; you</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/how-can-i-prevent-apostrophes-being-backslashed-out-php#comment-1242264</link>
    <description> &lt;p&gt;I presume by &quot;comas&quot; you mean &quot;apostrophes&quot; &lt;code&gt;&amp;#039;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;You need to know why it&#039;s doing this to decide the best method to stop it, as well as where in your code to do it.&lt;/p&gt;
&lt;p&gt;Does your server have &lt;code&gt;magic_quotes_gpc&lt;/code&gt; turned on? It&#039;s NOT common for it to be ON these days, but worth checking...&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #FF8000&quot;&gt;// Returns the current configuration setting of magic_quotes_gpc&lt;br /&gt;//Returns 0 if magic quotes gpc are OFF, 1 if ON&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;get_magic_quotes_gpc&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;();&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;If yes, the you could try the &lt;code&gt;stripslashes()&lt;/code&gt; function.&lt;br /&gt;
EG&lt;br /&gt;
&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;$code &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;= &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;stripslashes&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$adcode&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;\n&quot;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;; &lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;br /&gt;
But you may need to do that when you output it rather than input/save.&lt;/p&gt;
&lt;p&gt;Really though, you should have magic_quotes_gpc off. It&#039;s simply a nuisance these days and you shouldn&#039;t rely on it in code as it&#039;s off in recent PHP versions by default (depreciated in PHP 6, so wont even function), so most servers wont provide for it.&lt;/p&gt;
&lt;p&gt;As for the links, there are various ways to handle this.&lt;br /&gt;
Either require a full input entirely to input/save, so you just output &lt;code&gt;&amp;lt;a href=&amp;quot;&amp;#039;.$link.&amp;#039;&amp;quot;&amp;gt;&amp;quot;&amp;#039;.$lnk_text.&amp;#039;&amp;quot;&amp;lt;/a&amp;gt;&lt;/code&gt;, or just input/save just the domain and tld so you output the rest in the HTML, &lt;code&gt;&amp;lt;a href=&amp;quot;http://www.&amp;#039;.$link.&amp;#039;&amp;quot;&amp;gt;&amp;quot;&amp;#039;.$lnk_text.&amp;#039;&amp;quot;&amp;lt;/a&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Either way requires some form of checking the string with PHP. Does it have &quot;http://&quot; does it have &quot;www.&quot; etc. What you do and don&#039;t allow depends on how and where you construct the link.&lt;/p&gt;
&lt;p&gt;On a slight side note. Why do you set &lt;code&gt;$adcode&lt;/code&gt; to &lt;code&gt;$_POST[&amp;#039;adcode&amp;#039;]&lt;/code&gt;, then set &lt;code&gt;$code&lt;/code&gt; to &lt;code&gt;$adcode&lt;/code&gt;?&lt;br /&gt;
You can just use the &lt;code&gt;$_POST[&amp;#039;adcode&amp;#039;]&lt;/code&gt; for the error checking as in this instance you do very little with it. I only tend to assign it to a var if I&#039;m doing lots of checking with it and prefer a smaller var throughout the code.&lt;br /&gt;
Each to their own methods of course &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/wink.png&quot; title=&quot;Wink&quot; alt=&quot;Wink&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Tue, 02 Jun 2009 10:44:00 +0000</pubDate>
 <dc:creator>greg</dc:creator>
 <guid isPermaLink="false">comment 1242264 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
