<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>klkl &#187; PHP</title>
	<atom:link href="http://klkl.co.uk/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://klkl.co.uk</link>
	<description>it's easy to type</description>
	<lastBuildDate>Tue, 11 Oct 2011 14:53:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to Fix: Open Flash Chart, IE &amp; SSL Not Working</title>
		<link>http://klkl.co.uk/2011/03/01/how-to-fix-open-flash-chart-ie-ssl-not-working/</link>
		<comments>http://klkl.co.uk/2011/03/01/how-to-fix-open-flash-chart-ie-ssl-not-working/#comments</comments>
		<pubDate>Tue, 01 Mar 2011 08:00:07 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Blog Stuff]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[IE]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[OFC]]></category>
		<category><![CDATA[Open Flash Chart]]></category>
		<category><![CDATA[ssl]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=295</guid>
		<description><![CDATA[<p style="padding-left: 30px;"><span style="color: #333333;"><strong>&lt;?php<br />
</strong></span></p>
<p style="padding-left: 30px;"><span style="color: #333333;"><strong>//Headers Required for SSL in IE<br />
header(&#8221;Cache-Control: cache, must-revalidate&#8221;);<br />
header(&#8221;Pragma: public&#8221;);</strong></span></p>
<p style="padding-left: 30px;"><span style="color: #333333;"><strong>?&gt;</strong></span></p>
<p>Normally I don&#8217;t bother with making sure my projects are Internet Explorer compliant but the Open Flash Charts are just so pretty, and it&#8217;s not that difficult to fix, I felt I had to make sure they displayed correctly.</p>
]]></description>
			<content:encoded><![CDATA[<p style="padding-left: 30px;"><span style="color: #333333;"><strong>&lt;?php<br />
</strong></span></p>
<p style="padding-left: 30px;"><span style="color: #333333;"><strong>//Headers Required for SSL in IE<br />
header(&#8221;Cache-Control: cache, must-revalidate&#8221;);<br />
header(&#8221;Pragma: public&#8221;);</strong></span></p>
<p style="padding-left: 30px;"><span style="color: #333333;"><strong>?&gt;</strong></span></p>
<p>Normally I don&#8217;t bother with making sure my projects are Internet Explorer compliant but the Open Flash Charts are just so pretty, and it&#8217;s not that difficult to fix, I felt I had to make sure they displayed correctly.</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2011/03/01/how-to-fix-open-flash-chart-ie-ssl-not-working/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Debug: file_get_contents($Url);</title>
		<link>http://klkl.co.uk/2011/02/08/debug-file_get_contents/</link>
		<comments>http://klkl.co.uk/2011/02/08/debug-file_get_contents/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 08:00:07 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[php cache debug]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=283</guid>
		<description><![CDATA[<p>There is a variable $http_response_header</p>
<p>It contains the header reply information from the server&#8230;</p>
<p style="padding-left: 30px;"><strong>$var = file_get_contents($url);</strong></p>
<p style="padding-left: 30px;"><strong>var_dump($http_response_header);</strong></p>
<p>This really helped me figure out some problems when trying to cache google charts.</p>
]]></description>
			<content:encoded><![CDATA[<p>There is a variable $http_response_header</p>
<p>It contains the header reply information from the server&#8230;</p>
<p style="padding-left: 30px;"><strong>$var = file_get_contents($url);</strong></p>
<p style="padding-left: 30px;"><strong>var_dump($http_response_header);</strong></p>
<p>This really helped me figure out some problems when trying to cache google charts.</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2011/02/08/debug-file_get_contents/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>404 With jquery.gritter SOLVED</title>
		<link>http://klkl.co.uk/2010/11/15/404-with-jquery-gritter-solved/</link>
		<comments>http://klkl.co.uk/2010/11/15/404-with-jquery-gritter-solved/#comments</comments>
		<pubDate>Mon, 15 Nov 2010 20:12:36 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[gritter]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=263</guid>
		<description><![CDATA[<p>Gritter is a really good extension of jQuery&#8217;s functionality that is used to display information boxes to users. If you use firefox&#8217;s extension Firebug though or you look in your server logs then you may see that it&#8217;s causing 404 errors.</p>
<p>Whilst annoying the errors aren&#8217;t fatal. My applications have worked for long enough without solving the problem but it IS annoying and finally today I decided to do something about it. I found the solution on <a title="Duck Ranger" href="http://duckranger.com/2010/06/getting-404-with-jquery-gritter/" target="_self">this blog</a> and Duck Ranger gives much more sensible reasons for fixing the problem.</p>
<p>The error is caused by a Gritter&#8217;s CSS file creating a GET request to solve an IE bug but the request is for the current (CSS) directory which is forbidden.</p>
<p style="padding-left: 30px;"><span id="more-263"></span>.gritter-item-wrapper {<br />
position:relative;<br />
margin:0 0 10px 0;<br />
background:url(&#8217;.'); /* ie7/8 fix */<br />
}</p>
<p>Fortunately all I had to do as described in the previously mentioned blog is upload a real file. I opted for a 1 pixel transparent png.</p>
<p style="padding-left: 30px;">.gritter-item-wrapper {<br />
position:relative;<br />
margin:0 0 10px 0;<br />
background:url(&#8217;../images/blank.png&#8217;); /* ie7/8 fix */<br />
}</p>
<p>There we go&#8230; annoying error gone <img src='http://klkl.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></description>
			<content:encoded><![CDATA[<p>Gritter is a really good extension of jQuery&#8217;s functionality that is used to display information boxes to users. If you use firefox&#8217;s extension Firebug though or you look in your server logs then you may see that it&#8217;s causing 404 errors.</p>
<p>Whilst annoying the errors aren&#8217;t fatal. My applications have worked for long enough without solving the problem but it IS annoying and finally today I decided to do something about it. I found the solution on <a title="Duck Ranger" href="http://duckranger.com/2010/06/getting-404-with-jquery-gritter/" target="_self">this blog</a> and Duck Ranger gives much more sensible reasons for fixing the problem.</p>
<p>The error is caused by a Gritter&#8217;s CSS file creating a GET request to solve an IE bug but the request is for the current (CSS) directory which is forbidden.</p>
<p style="padding-left: 30px;"><span id="more-263"></span>.gritter-item-wrapper {<br />
position:relative;<br />
margin:0 0 10px 0;<br />
background:url(&#8217;.'); /* ie7/8 fix */<br />
}</p>
<p>Fortunately all I had to do as described in the previously mentioned blog is upload a real file. I opted for a 1 pixel transparent png.</p>
<p style="padding-left: 30px;">.gritter-item-wrapper {<br />
position:relative;<br />
margin:0 0 10px 0;<br />
background:url(&#8217;../images/blank.png&#8217;); /* ie7/8 fix */<br />
}</p>
<p>There we go&#8230; annoying error gone <img src='http://klkl.co.uk/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2010/11/15/404-with-jquery-gritter-solved/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting to MySQL Over SSH</title>
		<link>http://klkl.co.uk/2010/03/21/connecting-to-mysql-over-ssh/</link>
		<comments>http://klkl.co.uk/2010/03/21/connecting-to-mysql-over-ssh/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 14:06:56 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Miscellaneous]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[mySQL]]></category>
		<category><![CDATA[server]]></category>
		<category><![CDATA[SSH]]></category>
		<category><![CDATA[tunnel]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=251</guid>
		<description><![CDATA[<p>The last couple of days I&#8217;ve been thinking about setting up a local copy of my websites on my laptop so that I can develop them before I make them live.</p>
<p>Last night I enabled PHP on the apache server built into Mac OSX on my new laptop and installed MySQL on it. I also set up some bash aliases to rsync commands so that I could synchronise the websites from the server to the laptop and back again.</p>
<p>Now that I had local copies of the sites that are synchronised it was time to turn my attention to synchronising the databases between the server and my local machine. I could of configured the server&#8217;s MySQL installation to allow remote connections, however, I did not want to do this for security reasons. I decided that I would connect to the MySQL server over SSH by forwarding a port on my local machine to a remote port on the server.</p>
<p>First I needed to create an SSH tunnel using the following command</p>
<p style="padding-left: 30px;">ssh -fNg -L 3307:127.0.0.1:3306 server.host.name<span id="more-251"></span></p>
<p>The options for SSH are</p>
<ul>
<li>f
<ul>
<li>Requests SSH to background so that you do not have to keep a terminal connected to the server open</li>
</ul>
</li>
<li>N
<ul>
<li>Does not execute a remote command (useful for just forwarding ports)</li>
</ul>
</li>
<li>g
<ul>
<li>Allows remote hosts to connect to local forwarded ports</li>
</ul>
</li>
<li>L
<ul>
<li>Specifies that a local port (3307) is forwarded to the given host (server.host.name) and port (3306)</li>
</ul>
</li>
</ul>
<p>I created an alias to that command for easy use in future but I&#8217;ll need to make sure the tunnel is active before trying to connect to the remote server.</p>
<p>Next its time to turn our attention to actually connecting to the remote MySQL server.</p>
<p style="padding-left: 30px;">mysql -h 127.0.0.1 -P 3307 -u username -p</p>
<p>The Options:</p>
<ul>
<li>h specifies the host to connect to (must be 127.0.0.1)</li>
<li>P specifies the port to connect to (your locally forwarded port)</li>
<li>u specifies the username to connect with</li>
<li>p will prompt you for your password (&#8211;password=passtext can be used to give the password)</li>
</ul>
<p>Thats if I wanted to connect to the remote MySQL server on the command line. The latest phpmyadmin has an option for syncronizing databases in which case you can put the above details and it will compare the databases and allow you to choose what to synchronise.</p>
]]></description>
			<content:encoded><![CDATA[<p>The last couple of days I&#8217;ve been thinking about setting up a local copy of my websites on my laptop so that I can develop them before I make them live.</p>
<p>Last night I enabled PHP on the apache server built into Mac OSX on my new laptop and installed MySQL on it. I also set up some bash aliases to rsync commands so that I could synchronise the websites from the server to the laptop and back again.</p>
<p>Now that I had local copies of the sites that are synchronised it was time to turn my attention to synchronising the databases between the server and my local machine. I could of configured the server&#8217;s MySQL installation to allow remote connections, however, I did not want to do this for security reasons. I decided that I would connect to the MySQL server over SSH by forwarding a port on my local machine to a remote port on the server.</p>
<p>First I needed to create an SSH tunnel using the following command</p>
<p style="padding-left: 30px;">ssh -fNg -L 3307:127.0.0.1:3306 server.host.name<span id="more-251"></span></p>
<p>The options for SSH are</p>
<ul>
<li>f
<ul>
<li>Requests SSH to background so that you do not have to keep a terminal connected to the server open</li>
</ul>
</li>
<li>N
<ul>
<li>Does not execute a remote command (useful for just forwarding ports)</li>
</ul>
</li>
<li>g
<ul>
<li>Allows remote hosts to connect to local forwarded ports</li>
</ul>
</li>
<li>L
<ul>
<li>Specifies that a local port (3307) is forwarded to the given host (server.host.name) and port (3306)</li>
</ul>
</li>
</ul>
<p>I created an alias to that command for easy use in future but I&#8217;ll need to make sure the tunnel is active before trying to connect to the remote server.</p>
<p>Next its time to turn our attention to actually connecting to the remote MySQL server.</p>
<p style="padding-left: 30px;">mysql -h 127.0.0.1 -P 3307 -u username -p</p>
<p>The Options:</p>
<ul>
<li>h specifies the host to connect to (must be 127.0.0.1)</li>
<li>P specifies the port to connect to (your locally forwarded port)</li>
<li>u specifies the username to connect with</li>
<li>p will prompt you for your password (&#8211;password=passtext can be used to give the password)</li>
</ul>
<p>Thats if I wanted to connect to the remote MySQL server on the command line. The latest phpmyadmin has an option for syncronizing databases in which case you can put the above details and it will compare the databases and allow you to choose what to synchronise.</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2010/03/21/connecting-to-mysql-over-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Equivalent to the SQL IN (&#8230;) Statement</title>
		<link>http://klkl.co.uk/2009/07/18/php-equivalent-to-the-sql-in-statement/</link>
		<comments>http://klkl.co.uk/2009/07/18/php-equivalent-to-the-sql-in-statement/#comments</comments>
		<pubDate>Sat, 18 Jul 2009 13:21:28 +0000</pubDate>
		<dc:creator>klkl</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Pharmacy]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[dm+d]]></category>
		<category><![CDATA[NHS]]></category>
		<category><![CDATA[nhsbsa]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://klkl.co.uk/?p=203</guid>
		<description><![CDATA[<p>Recently I&#8217;ve been looking at using the NHS Business Service Authority&#8217;s Dictionary of Medicines and Devices for my own nefarious purposes. The Information (data that has meaning) is distributed as XML files.</p>
<p>I haven&#8217;t come across a database design for the data so I&#8217;ve come up with my own and to import the data into it I&#8217;ve been using PHP&#8217;s XML DOM functionality (<a title="Parse XML in PHP" href="http://klkl.co.uk/2007/10/23/how-to-parse-an-xml-file-using-php-part-1/" target="_blank">a different technique than I described in my earlier post &#8230;</a>). Because the files are published according to specified standards I decided to save myself some programming time by adopting their terminology for my database design so that I could write very little code to prepare the data and insert it into the database.</p>
<p>However, I wanted to test that the nodes I was expecting were what was being prepared for insertion into the database. One reason it may not is if the XML file has been reformatted with indents (<a title="HowTo Quickly Indent XML" href="http://klkl.co.uk/2009/07/14/how-to-indent-xml-quickly/" target="_blank">mentioned in this post</a>) What I needed was an equivalent to SQLs IN statement. The solution is to use PHP&#8217;s in_array() function like so&#8230;</p>
<p style="padding-left: 30px;"><strong>$desirable_values = array(&#8217;CD&#8217;, &#8216;CDDT&#8217;, &#8216;CDPREV&#8217;, &#8216;DESC&#8217;);<br />
if ( in_array( $variable_to_test, $desirable_values) ) {<br />
//Do Your Stuff<br />
}</strong></p>
<p>It saves you having to test if your variable is equal to each of the variables you want to test thus making your code cleaner and shorter.</p>
]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been looking at using the NHS Business Service Authority&#8217;s Dictionary of Medicines and Devices for my own nefarious purposes. The Information (data that has meaning) is distributed as XML files.</p>
<p>I haven&#8217;t come across a database design for the data so I&#8217;ve come up with my own and to import the data into it I&#8217;ve been using PHP&#8217;s XML DOM functionality (<a title="Parse XML in PHP" href="http://klkl.co.uk/2007/10/23/how-to-parse-an-xml-file-using-php-part-1/" target="_blank">a different technique than I described in my earlier post &#8230;</a>). Because the files are published according to specified standards I decided to save myself some programming time by adopting their terminology for my database design so that I could write very little code to prepare the data and insert it into the database.</p>
<p>However, I wanted to test that the nodes I was expecting were what was being prepared for insertion into the database. One reason it may not is if the XML file has been reformatted with indents (<a title="HowTo Quickly Indent XML" href="http://klkl.co.uk/2009/07/14/how-to-indent-xml-quickly/" target="_blank">mentioned in this post</a>) What I needed was an equivalent to SQLs IN statement. The solution is to use PHP&#8217;s in_array() function like so&#8230;</p>
<p style="padding-left: 30px;"><strong>$desirable_values = array(&#8217;CD&#8217;, &#8216;CDDT&#8217;, &#8216;CDPREV&#8217;, &#8216;DESC&#8217;);<br />
if ( in_array( $variable_to_test, $desirable_values) ) {<br />
//Do Your Stuff<br />
}</strong></p>
<p>It saves you having to test if your variable is equal to each of the variables you want to test thus making your code cleaner and shorter.</p>
]]></content:encoded>
			<wfw:commentRss>http://klkl.co.uk/2009/07/18/php-equivalent-to-the-sql-in-statement/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

