<?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>am i works? &#187; how too?</title>
	<atom:link href="http://amiworks.co.in/talk/category/how-too/feed/" rel="self" type="application/rss+xml" />
	<link>http://amiworks.co.in/talk</link>
	<description>all about my work</description>
	<lastBuildDate>Sat, 10 Mar 2012 20:22:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>How To Catch PHP Fatal Error In CodeIgniter</title>
		<link>http://amiworks.co.in/talk/how-to-catch-php-fatal-error-in-codeigniter/</link>
		<comments>http://amiworks.co.in/talk/how-to-catch-php-fatal-error-in-codeigniter/#comments</comments>
		<pubDate>Sat, 01 Jan 2011 14:32:29 +0000</pubDate>
		<dc:creator>Amit Kumar Singh</dc:creator>
				<category><![CDATA[how too?]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php fatal errors]]></category>

		<guid isPermaLink="false">http://amiworks.co.in/talk/?p=372</guid>
		<description><![CDATA[My last few blog post’s are result of the project that I am currently working on, and this blog is also in that series. We needed to catch PHP Fatal Errors in the production environment and notify about it to developers, also at the same time, showing our beautiful fail whale page to user instead [...]]]></description>
			<content:encoded><![CDATA[<p>My <a href="http://amiworks.co.in/talk/simple-way-to-add-global-exception-handling-in-codeigniter/">last</a> <a href="http://amiworks.co.in/talk/installing-pear-and-phpunit-on-wamp-and-windows-7/">few</a> <a href="http://amiworks.co.in/talk/testing-extjs-application-with-selenium-few-pointers/">blog</a> post’s are result of the project that I am currently working on, and this blog is also in that series.</p>
<p>We needed to catch PHP Fatal Errors in the production environment and notify about it to developers, also at the same time, showing our beautiful fail whale page to user instead of ugly error or a white screen of death.</p>
<p>Here I will show you how to do this in CodeIgniter, though credit for this idea goes to <a href="http://stackoverflow.com/questions/277224/how-do-i-catch-a-php-fatal-error/3795403#3795403">hipertracker</a>.</p>
<p>First of all you will need to setup a hook, so update your <em>hooks.php</em> file with following code</p>
<pre>	$hook['pre_system'][] = array(
	    'class'    =&gt; 'PHPFatalError',
            'function' =&gt; 'setHandler',
            'filename' =&gt; 'PHPFatalError.php',
   	    'filepath' =&gt; 'hooks'
);</pre>
<p>Now put the code shown below in <em>PHPFatalError.php</em> file in your applications <em>hooks</em> folder.</p>
<p><script src="https://gist.github.com/761775.js?file=PHPFatalError.php"></script></p>
<p>This is the simplifed version of what I have done, so please update <em>handleShutdown </em>function<em> </em>as per your needs.</p>
<div style="margin: 10px; background: #ffffcc; font-size: 1.2em; font-weight: bold; border: #aaaaaa 1px solid; padding: 5px;">Check out PHPCamp a place to share news, views and articles that are useful to <a style="color: #008888; text-decoration: underline;" title="PHP community where you learn something new every day " href="http://phpcamp.net/?utm_medium=blog_post&amp;utm_source=amiworks_co_in&amp;utm_campaign=phpunit_win7">PHP community</a>.</div>
<!-- WP Boastful Plugin by WPoets Team --> <div id='boastful'><strong></strong></div><hr style="border-top:black solid 1px" /><a href="http://amiworks.co.in/talk/how-to-catch-php-fatal-error-in-codeigniter/">How To Catch PHP Fatal Error In CodeIgniter</a> was first posted on January 1, 2011 at 8:02 pm.<br />©2008 "<a href="http://amiworks.co.in/talk">am i works?</a>". <br />]]></content:encoded>
			<wfw:commentRss>http://amiworks.co.in/talk/how-to-catch-php-fatal-error-in-codeigniter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP5 patch for FunctionList plugin of Notepad + +</title>
		<link>http://amiworks.co.in/talk/php5-patch-for-functionlist-plugin-of-notepad/</link>
		<comments>http://amiworks.co.in/talk/php5-patch-for-functionlist-plugin-of-notepad/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 16:43:32 +0000</pubDate>
		<dc:creator>Amit Kumar Singh</dc:creator>
				<category><![CDATA[how too?]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[functionlist]]></category>
		<category><![CDATA[notepad++]]></category>

		<guid isPermaLink="false">http://amiworks.co.in/talk/?p=365</guid>
		<description><![CDATA[As you may know Notepad++ is my preferred development tool for PHP, and two months back I found FunctionList plugin that shows list of function in a opened PHP file, and it increased my productivity almost immediately. Only drawback was that it showed just function list and not variables. And today I found this neat [...]]]></description>
			<content:encoded><![CDATA[<p>As you may know Notepad++ is my preferred development tool for PHP, and two months back I found <a href="http://sourceforge.net/projects/npp-plugins/files/Function%20List/">FunctionList</a> plugin that shows list of function in a opened PHP file, and it increased my productivity almost immediately.</p>
<p>Only drawback was that it showed just function list and not variables.</p>
<p>And today I found this <a href="http://www.geoffray.be/blog/php/patch-php5-pour-npp-function-list">neat patch of this plugin by Geoffray Warnants</a><em></em> which now makes it even better with icons and also showing variable.</p>
<div style="float: left;">
<p>This is how it looked before</p>
<p><a href="http://amiworks.co.in/talk/wp-content/uploads/2010/12/functionlist-default.png"><img style="background-image: none; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="functionlist-default" src="http://amiworks.co.in/talk/wp-content/uploads/2010/12/functionlist-default.png" border="0" alt="functionlist-default" width="262" height="772" /></a></p>
</div>
<div style="float: left;">
<p>This is how it looks after the patch</p>
<p><a href="http://amiworks.co.in/talk/wp-content/uploads/2010/12/functionlist-php-patched.png"><img style="background-image: none; margin: 5px; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="functionlist-php-patched" src="http://amiworks.co.in/talk/wp-content/uploads/2010/12/functionlist-php-patched.png" border="0" alt="functionlist-php-patched" width="262" height="772" /></a></p>
</div>
<p><a href="http://www.geoffray.be/blog/php/patch-php5-pour-npp-function-list">Download the patch here</a> (post is in French, scroll down to download the patch)</p>
<!-- WP Boastful Plugin by WPoets Team --> <div id='boastful'><strong></strong></div><hr style="border-top:black solid 1px" /><a href="http://amiworks.co.in/talk/php5-patch-for-functionlist-plugin-of-notepad/">PHP5 patch for FunctionList plugin of Notepad + +</a> was first posted on December 14, 2010 at 10:13 pm.<br />©2008 "<a href="http://amiworks.co.in/talk">am i works?</a>". <br />]]></content:encoded>
			<wfw:commentRss>http://amiworks.co.in/talk/php5-patch-for-functionlist-plugin-of-notepad/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing PEAR and PHPUnit on WAMP and Windows 7</title>
		<link>http://amiworks.co.in/talk/installing-pear-and-phpunit-on-wamp-and-windows-7/</link>
		<comments>http://amiworks.co.in/talk/installing-pear-and-phpunit-on-wamp-and-windows-7/#comments</comments>
		<pubDate>Sat, 30 Oct 2010 02:51:00 +0000</pubDate>
		<dc:creator>Amit Kumar Singh</dc:creator>
				<category><![CDATA[how too?]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[pear]]></category>
		<category><![CDATA[phpunit]]></category>
		<category><![CDATA[wamp]]></category>

		<guid isPermaLink="false">http://amiworks.co.in/talk/installing-pear-and-phpunit-on-wamp-and-windows-7/</guid>
		<description><![CDATA[In the project that i am currently working on, we decided to use PHPUnit for doing our unit testing, and i found that it was not a straight forward thing to install that I had thought it would be. I had to start by installing Pear, and as soon as i type ‘go-pear’ in command [...]]]></description>
			<content:encoded><![CDATA[<p>    In the project that i am currently working on, we decided to use PHPUnit for doing our unit testing, and i found that it was not a straight forward thing to install that I had thought it would be. I had to start by installing Pear, and as soon as i type ‘go-pear’ in command prompt and pressed enter key I got my first error.</p>
<p>So here are the steps needed to install PEAR and PHPUnit error free on WAMP.</p>
<p>So let’s start with PEAR, please note my Wampserver is installed on drive ‘H’,&#160; substitute it with your own.</p>
<p>  <span id="more-345"></span><br />
<h2>Steps to Install PEAR</h2>
<p>1 ) Locate the &quot;php.ini&quot; file. In my case, I found it at this path:</p>
<pre>H:\wamp\bin\php\php5.3.0\php.ini</pre>
<p>Don&#8217;t use the WAMP system tray icon to edit this file.</p>
<p>2 ) Find the following line:</p>
<pre>;phar.require_hash = On</pre>
<p>3 ) Uncomment the &quot;;phar.require_hash = On&quot; line by removing the semi-colon.</p>
<p>4 ) Change &quot;On&quot; to &quot;Off&quot;.</p>
<pre>phar.require_hash = Off</pre>
<p>5 ) Save the file.</p>
<p>6 ) Now on command prompt type ‘<em>go-pear</em>’</p>
<p>7 ) Select ‘<em>local</em>’ to the question asked.. and follow the instructions.</p>
<p>8 ) Now we need to edit the ‘<em>php.ini</em>’ again to add pear include path. Open ‘<em>php.ini</em>’ that we found in php5.3.0 folder and search for ‘go-pear’, you will see </p>
<pre>;***** Added by go-pear
include_path=&quot;.;H:\wamp\bin\php\php5.3.0\pear&quot; 

;*****</pre>
<p>Copy these three lines and paste it to ‘<em>php.ini</em>’ file which is located at : </p>
<pre>H:\wamp\bin\apache\apache2.2.11\bin </pre>
<p>9 ) Restart the apache, and you have PEAR installed on you machine.</p>
<p>But we are not done yet, to use ‘pear’ command in your command prompt from anywhere you will need to modify the windows environment variables. </p>
<p>10 ) Go to <em>control panel –&gt; system</em>&#160; and click on the ‘<em>advanced system settings</em>’ (it is on the left sidebar)</p>
<p>11 ) Click on the environment variables button and <em>new/edit</em> ‘PATH’ variable and add&#160; </p>
<pre>‘H:\wamp\bin\php\php5.3.0’</pre>
<p>in your path. You also need to add a new variable ‘PHP_PEAR_PHP_BIN’ and set the value to </p>
<pre>‘H:\wamp\bin\php\php5.3.0\php.exe’</pre>
<p>close you command prompt and open it again for these changes to take effect.</p>
<p>12 ) now type ‘<em>pear’</em> on the command prompt and you should see pear command help printed for you.</p>
<p>Now that PEAR is installed, let’s install the PHPUnit.</p>
<div style="margin: 10px; background: #ffffcc; font-size: 1.2em; font-weight: bold; border: #aaaaaa 1px solid; padding: 5px;">Check out PHPCamp a place to share news, views and articles that are useful to <a style="color: #008888; text-decoration: underline;" title="PHP community where you learn something new every day " href="http://phpcamp.net/?utm_medium=blog_post&amp;utm_source=amiworks_co_in&amp;utm_campaign=pear_phpunit_win7">PHP community</a>.</div>
<h2>Steps to install PHPUnit</h2>
<p>1 ) On ‘C’ drive create a folder named ‘php5’</p>
<p>2 )Then on command prompt type:</p>
<pre> pear upgrade pear</pre>
<p>2 ) Once PEAR&#160; is updated, on command prompt type:</p>
<pre> pear channel-discover components.ez.no 

 pear channel-discover pear.phpunit.de

 pear channel-discover pear.symfony-project.com</pre>
<p>4 )Finally type: </p>
<pre> pear install --alldeps phpunit/PHPUnit</pre>
<p>And with this you should have PHPUnit installed on your system. </p>
<p>In my quest to install PHPUnit I found help from following articles</p>
<ol>
<li><a href="http://stackoverflow.com/questions/1652941/why-am-i-receiving-an-error-when-installing-pear">Stackoverflow</a></li>
<li><a href="http://www.wampserver.com/phorum/read.php?2,67257">Wampserver forum</a></li>
<li><a href="http://usingzendframework.blogspot.com/2007/12/setting-up-phpunit.html">Using Zend Framework blog</a></li>
</ol>
<!-- WP Boastful Plugin by WPoets Team --> <div id='boastful'><strong></strong></div><hr style="border-top:black solid 1px" /><a href="http://amiworks.co.in/talk/installing-pear-and-phpunit-on-wamp-and-windows-7/">Installing PEAR and PHPUnit on WAMP and Windows 7</a> was first posted on October 30, 2010 at 8:21 am.<br />©2008 "<a href="http://amiworks.co.in/talk">am i works?</a>". <br />]]></content:encoded>
			<wfw:commentRss>http://amiworks.co.in/talk/installing-pear-and-phpunit-on-wamp-and-windows-7/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
		<item>
		<title>Simple Way To Add Global Exception Handling In CodeIgniter</title>
		<link>http://amiworks.co.in/talk/simple-way-to-add-global-exception-handling-in-codeigniter/</link>
		<comments>http://amiworks.co.in/talk/simple-way-to-add-global-exception-handling-in-codeigniter/#comments</comments>
		<pubDate>Sat, 02 Oct 2010 13:28:40 +0000</pubDate>
		<dc:creator>Amit Kumar Singh</dc:creator>
				<category><![CDATA[how too?]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[codeigniter]]></category>
		<category><![CDATA[exception handling]]></category>

		<guid isPermaLink="false">http://amiworks.co.in/talk/?p=338</guid>
		<description><![CDATA[I am working on a project where we needed to capture exceptions at a global level instead of doing it at every step as they were not critical, but important for us to know. The idea was that whenever such an exception occur on production we should send an email to developers mailing list so [...]]]></description>
			<content:encoded><![CDATA[<p>I am working on a project where we needed to capture exceptions at a global level instead of doing it at every step as they were not critical, but important for us to know.</p>
<p>The idea was that whenever such an exception occur on production we should send an email to developers mailing list so that someone can investigate it.</p>
<p>As usual I did a quick google search and i found <a href="http://codeigniter.com/forums/viewthread/141573/">two</a> <a href="http://codeigniter.com/forums/viewthread/126752/">forum</a> posts in CodeIgniter and <a href="http://stackoverflow.com/questions/260597/in-codeigniter-how-can-i-have-php-error-messages-emailed-to-me">one</a> on stackoverflow, but they all fall short as CodeIgniter does not set’s any default exception handlers they way it sets the native error handler.</p>
<p>So here is a quick tutorial on how you can do that.<br />
<span id="more-338"></span><br />
First of all you need to setup a hook, so put following code in <em>hook.php</em> file in config folder.</p>
<pre>$hook['pre_controller'][] = array(
                   'class'    =&gt; 'ExceptionHook',
                   'function' =&gt; 'SetExceptionHandler',
                   'filename' =&gt; 'ExceptionHook.php',
                   'filepath' =&gt; 'hooks'
                  );</pre>
<p>Now I am using <em>pre_controller</em> hook as I wanted to use $CI object which is available at this stage.</p>
<p>Now put the code shown below in the file named <em>ExceptionHook.php</em> in your application’s <em>hooks</em> folder.</p>
<p><script src="http://gist.github.com/607550.js?file=ExceptionHook.php"></script> </p>
<p>Also if you need to capture and email native PHP errors, you can do so by extending the Exceptions library as shown in the code below.</p>
<p><script src="http://gist.github.com/607550.js?file=MY_Exceptions.php"></script></p>
<p>While I have used the simple PHP mail function in the example above, you can use CI&#8217;s mail library as well. </p>
<p>If you have any doubts feel free to ask in comments below.</p>
<!-- WP Boastful Plugin by WPoets Team --> <div id='boastful'><strong></strong></div><hr style="border-top:black solid 1px" /><a href="http://amiworks.co.in/talk/simple-way-to-add-global-exception-handling-in-codeigniter/">Simple Way To Add Global Exception Handling In CodeIgniter</a> was first posted on October 2, 2010 at 6:58 pm.<br />©2008 "<a href="http://amiworks.co.in/talk">am i works?</a>". <br />]]></content:encoded>
			<wfw:commentRss>http://amiworks.co.in/talk/simple-way-to-add-global-exception-handling-in-codeigniter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to get Latitude/Longitude from an address (or Geocoding ) using PHP</title>
		<link>http://amiworks.co.in/talk/how-to-get-latitudelongitude-from-an-address-or-geocoding-using-php/</link>
		<comments>http://amiworks.co.in/talk/how-to-get-latitudelongitude-from-an-address-or-geocoding-using-php/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 10:02:15 +0000</pubDate>
		<dc:creator>Amit Kumar Singh</dc:creator>
				<category><![CDATA[how too?]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://amiworks.co.in/talk/how-to-get-latitudelongitude-from-an-address-or-geocoding-using-php/</guid>
		<description><![CDATA[While Google’s documents for maps API does good job in showing how to get lat/long from an address in JavaScript they do not really show any example of doing the same with PHP. &#160; So to make you life simple here is a small script in PHP that does that. &#160; &#160; $geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address=573/1,+Jangli+Maharaj+Road,+Deccan+Gymkhana,+Pune,+Maharashtra,+India&#38;sensor=false'); $output= json_decode($geocode); [...]]]></description>
			<content:encoded><![CDATA[<p>While Google’s documents for maps API does good job in showing how to get lat/long from an address in JavaScript they do not really show any example of doing the same with PHP.</p>
<p>&#160;</p>
<p>So to make you life simple here is a small script in PHP that does that.</p>
<p>&#160;</p>
<p>&#160;</p>
<pre class="code">$geocode=file_get_contents('<a href="http://maps.google.com/maps/api/geocode/json?address=573/1,+Jangli+Maharaj+Road,+Deccan+Gymkhana,+Pune,+Maharashtra,+India&amp;sensor=false');">http://maps.google.com/maps/api/geocode/json?address=573/1,+Jangli+Maharaj+Road,+Deccan+Gymkhana,+Pune,+Maharashtra,+India&amp;sensor=false');</a>

$output= json_decode($geocode);

$lat = $output-&gt;results[0]-&gt;geometry-&gt;location-&gt;lat;
$long = $output-&gt;results[0]-&gt;geometry-&gt;location-&gt;lng;</pre>
<p>&#160;</p>
<p>The line above makes a request to Google maps API. Passes the address, and receives the response in JSON format.</p>
<p>The URL has following options </p>
<pre><a href="http://maps.google.com/maps/api/geocode/output?parameters">http://maps.google.com/maps/api/geocode/<i>output</i>?<i>parameters</a></i></pre>
<p>where <em>output</em> can be 1) JSON or 2) XML </p>
<p>For more details about parameters check out the <a href="http://code.google.com/apis/maps/documentation/geocoding/index.html">Google’s geocoding documentation</a>.</p>
<!-- WP Boastful Plugin by WPoets Team --> <div id='boastful'><strong></strong></div><hr style="border-top:black solid 1px" /><a href="http://amiworks.co.in/talk/how-to-get-latitudelongitude-from-an-address-or-geocoding-using-php/">How to get Latitude/Longitude from an address (or Geocoding ) using PHP</a> was first posted on March 10, 2010 at 3:32 pm.<br />©2008 "<a href="http://amiworks.co.in/talk">am i works?</a>". <br />]]></content:encoded>
			<wfw:commentRss>http://amiworks.co.in/talk/how-to-get-latitudelongitude-from-an-address-or-geocoding-using-php/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		</item>
		<item>
		<title>How To Fix MySQL Error &#8211; Error Code 30</title>
		<link>http://amiworks.co.in/talk/how-to-fix-mysql-error-error-code-30/</link>
		<comments>http://amiworks.co.in/talk/how-to-fix-mysql-error-error-code-30/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 18:31:00 +0000</pubDate>
		<dc:creator>Amit Kumar Singh</dc:creator>
				<category><![CDATA[how too?]]></category>
		<category><![CDATA[/tmp corrupt]]></category>
		<category><![CDATA[errorcode 30]]></category>
		<category><![CDATA[mysql error]]></category>

		<guid isPermaLink="false">http://amiworks.co.in/talk/how-to-fix-mysql-error-error-code-30/</guid>
		<description><![CDATA[Yesterday was one of those days when things that can go wrong went wrong and today was MySQL day, and problem when accessing any table on a live site resulted in following error MySQL Error - Can't create/write to file '/tmp/#sql_7d3f_0.MYI' (Errcode: 30) It took me some time to figure out that the error was [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday was one of those days when things that can go wrong went wrong and today was MySQL day, and problem when accessing any table on a live site resulted in following error </p>
<pre>MySQL Error - Can't create/write to file '/tmp/#sql_7d3f_0.MYI' (Errcode: 30)</pre>
<p>It took me some time to figure out that the error was due to <em>/usr/tmpDSK</em> getting corrupted, and and not really a problem with MySQL or our database as we were thinking all this time, and as usual google came to rescue. </p>
<p>Here are the steps to fix this for cpanel users…&#160; run the following commands in the order mentioned</p>
</p>
<pre>/usr/sbin/lsof /tmp

/bin/umount -l /tmp

/bin/umount -l /var/tmp

/bin/rm -fv /usr/tmpDSK

/scripts/securetmp</pre>
<p></p>
<p>This will create a new <em>/tmp</em> partition for you and the problem will go away. By the way error code 30 means that file system is read only.</p>
<!-- WP Boastful Plugin by WPoets Team --> <div id='boastful'><strong></strong></div><hr style="border-top:black solid 1px" /><a href="http://amiworks.co.in/talk/how-to-fix-mysql-error-error-code-30/">How To Fix MySQL Error &ndash; Error Code 30</a> was first posted on December 3, 2009 at 12:01 am.<br />©2008 "<a href="http://amiworks.co.in/talk">am i works?</a>". <br />]]></content:encoded>
			<wfw:commentRss>http://amiworks.co.in/talk/how-to-fix-mysql-error-error-code-30/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Where is MySQL Gone Away?</title>
		<link>http://amiworks.co.in/talk/where-is-mysql-gone-away/</link>
		<comments>http://amiworks.co.in/talk/where-is-mysql-gone-away/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 16:51:09 +0000</pubDate>
		<dc:creator>Amit Kumar Singh</dc:creator>
				<category><![CDATA[how too?]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://amiworks.co.in/talk/?p=316</guid>
		<description><![CDATA[Last Sunday I got to work on a very interesting problem in WordPress which I initially thought could be solved in like 5 mins, but alas it took me almost 7 hours before I found and fixed the problem. Let me describe the problem, I was running a simple xml parsing script whose task was [...]]]></description>
			<content:encoded><![CDATA[<p>Last Sunday I got to work on a very interesting problem in WordPress which I initially thought could be solved in like 5 mins, but alas it took me almost 7 hours before I found and fixed the problem.</p>
<p>Let me describe the problem, I was running a simple xml parsing script whose task was to parse the xml file and insert the content into WordPress database as a post, everything was working fine except the <em>‘INSERT’</em> statement was failing with out any errors. Basically everything would run but nothing would get inserted into database and no errors. We had used the <em>‘wp_insert_post’</em> function in  <em>‘post.php’</em> file to handle the insertion of post, which was returning ‘0’ instead.</p>
<p>After lot’s of time spend checking and cross checking the sql statements for error and PHP code logic, i finally found the problem which was a small kinda cryptic error <strong>‘MySQL server has gone away’ </strong>for every single query that was getting executed in the script.</p>
<p>Well, a quick google search took me to <a title="MySQL server gone away" href="http://dev.mysql.com/doc/refman/5.0/en/gone-away.html">MySQL manual</a> page where it list bunch of possibilities on why the error might be coming.</p>
<p>To me the most logical one were</p>
<ol>
<li>
<ol>
<li>You tried to run a query after closing the connection to the server. This indicates a logic error in the application that should be corrected.</li>
<li>A client application running on a different host does not have the necessary privileges to connect to the MySQL server from that host.</li>
<li>You have encountered a timeout on the server side and the automatic reconnection in the client is disabled (the reconnect flag in the MYSQL structure is equal to 0).</li>
<li>You can also get these errors if you send a query to the server that is incorrect or too large.</li>
<li>You are using a Windows client and the server had dropped the connection (probably because wait_timeout expired) before the command was issued.</li>
</ol>
</li>
</ol>
<p>I investigated each one but it turned out that because a query was taking a bit to long to execute MySQL closed the connection and refused all further request from the client.</p>
<p>So you might be wondering what was the <strong>Solution </strong>to this problem.</p>
<p>Well <a href="http://robsnotebook.com/">Rob of Rob’s notebook</a> had the almost perfect solution for it. He <a href="http://robsnotebook.com/wordpress-mysql-gone-away">created a replacement file for<em> ‘wpdb.php’</em></a> which takes care of this problem, yeah it is temporary and you have to remember to replace this file every time you do an WordPress upgrade but it works.</p>
<p>If you are facing this problem go download it and replace you <em>‘wpdb’</em> file and save yourself some time.</p>
<div style="border-bottom: #aaaaaa 1px solid; border-left: #aaaaaa 1px solid; padding-bottom: 5px; margin: 10px; padding-left: 5px; padding-right: 5px; background: #ffffcc; font-size: 1.4em; border-top: #aaaaaa 1px solid; font-weight: bold; border-right: #aaaaaa 1px solid; padding-top: 5px">Check out <a style="color: #008888; text-decoration: underline" title="PHP community where you learn something new every day " href="http://phpcamp.net/?utm_medium=blog_post&amp;utm_source=new_blog_at_amiworks&amp;utm_campaign=where%20MySQL%20Server%20gone">PHPCamp.net</a> a article sharing website relevant to our own PHP community</div>
<!-- WP Boastful Plugin by WPoets Team --> <div id='boastful'><strong></strong></div><hr style="border-top:black solid 1px" /><a href="http://amiworks.co.in/talk/where-is-mysql-gone-away/">Where is MySQL Gone Away?</a> was first posted on November 11, 2009 at 10:21 pm.<br />©2008 "<a href="http://amiworks.co.in/talk">am i works?</a>". <br />]]></content:encoded>
			<wfw:commentRss>http://amiworks.co.in/talk/where-is-mysql-gone-away/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Media Manager Browse Button Disabled In Joomla</title>
		<link>http://amiworks.co.in/talk/media-manager-browse-button-disabled-in-joomla/</link>
		<comments>http://amiworks.co.in/talk/media-manager-browse-button-disabled-in-joomla/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 05:00:00 +0000</pubDate>
		<dc:creator>Amit Kumar Singh</dc:creator>
				<category><![CDATA[how too?]]></category>
		<category><![CDATA[joomla]]></category>
		<category><![CDATA[media manager]]></category>

		<guid isPermaLink="false">http://amiworks.co.in/talk/media-manager-browse-button-disabled-in-joomla/</guid>
		<description><![CDATA[Problem : No matter how many time you click on the media manager’s browse button nothing happens. It used to work few days back but not any more. It is as if the the media manager buttons has been disabled. If you were facing these problems it is most probably due to the Flash uploader [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Problem</strong> : No matter how many time you click on the media manager’s browse button nothing happens. It used to work few days back but not any more.</p>
<p>It is as if the the media manager buttons has been disabled.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="media_manager_problem" src="http://amiworks.co.in/talk/wp-content/uploads/2009/08/media_manager_problem.jpg" border="0" alt="media_manager_problem" width="440" height="189" /></p>
<p>If you were facing these problems it is most probably due to the Flash uploader not working properly with Flash version installed on your system.</p>
<p><strong>Solution</strong>:</p>
<p>The simplest solution to fix this issue is to go to,</p>
<p><em>Global Configuration –&gt; Systems –&gt;Media settings.</em></p>
<p>And select ‘<em>No</em>’ for ‘<em>Enable Flash Uploader</em>’ setting, and save the settings.</p>
<p><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="mediamanager_config" src="http://amiworks.co.in/talk/wp-content/uploads/2009/08/mediamanager_config.png" border="0" alt="mediamanager_config" width="395" height="71" /></p>
<p>That’s it, this simple. Now go back to you media manager and upload files to your heart’s content.</p>
<!-- WP Boastful Plugin by WPoets Team --> <div id='boastful'><strong></strong></div><hr style="border-top:black solid 1px" /><a href="http://amiworks.co.in/talk/media-manager-browse-button-disabled-in-joomla/">Media Manager Browse Button Disabled In Joomla</a> was first posted on August 19, 2009 at 10:30 am.<br />©2008 "<a href="http://amiworks.co.in/talk">am i works?</a>". <br />]]></content:encoded>
			<wfw:commentRss>http://amiworks.co.in/talk/media-manager-browse-button-disabled-in-joomla/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>How to use SVN and Git together to get the best of both worlds in Windows</title>
		<link>http://amiworks.co.in/talk/how-to-use-svn-and-git-together-to-get-the-best-of-both-worlds-in-windows/</link>
		<comments>http://amiworks.co.in/talk/how-to-use-svn-and-git-together-to-get-the-best-of-both-worlds-in-windows/#comments</comments>
		<pubDate>Mon, 17 Aug 2009 10:21:59 +0000</pubDate>
		<dc:creator>Amit Kumar Singh</dc:creator>
				<category><![CDATA[how too?]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[git-svn]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://amiworks.co.in/talk/?p=296</guid>
		<description><![CDATA[I have been using SVN to manage my source code for last three years, I can say I am quite happy with it, except for one problem, it was not possible to commit the code unless I was directly connected to my office network. Then I heard about DVCS and Git. I found solution to [...]]]></description>
			<content:encoded><![CDATA[<p>I have been using <a href="http://subversion.tigris.org/" target="_blank">SVN</a> to manage my source code for last three years, I can say I am quite happy with it, except for one problem, it was not possible to commit the code unless I was directly connected to my office network.</p>
<p>Then I heard about DVCS and <a href="http://git-scm.com/" target="_blank">Git</a>. I found solution to one of my big problem, ability to commit code while I am not connected to office network, and share code with my teammates.</p>
<p>Their was only one small problem we didn’t wanted to loose the benefits of centralized repository, and we use Windows  OS( let’s not get into windows vs linux, i will win). So last 3-4 months I was looking for different DVCS systems with better windows support and i experimented with Mercurial (TrototoiseHg is good), but i think Git wins the race of DVCS hands down, and with popularity of GitHub I don’t see much choice here.</p>
<p>And finally I found about <a href="http://www.kernel.org/pub/software/scm/git/docs/git-svn.html" target="_blank">git-svn</a>, and I was on my way.</p>
<p>Here are the commands and steps that you can use to manage Git and SVN together.</p>
<ol>
<li>Create a working copy(or actually a git repository ) using
<pre class="akcode">git svn clone –s &lt;path to ur svn rep, eg https://akjoomgallery.googlecode.com/svn/trunk/&gt;</pre>
</li>
<li>Get the source from svn repository to your git repository using
<pre class="akcode">git svn fetch</pre>
<p>(only needs to be done first time, it is slow and time consuming process)</li>
<li>When you need to update your working copy  you use
<pre class="akcode">git svn rebase</pre>
</li>
<li>When you need to commit back to svn repository just use
<pre class="akcode">git svn dcommit</pre>
</li>
</ol>
<p>I used above commands in Git bash shell that comes with Git.</p>
<p>Also note their would be time when we have some changes in the Git repository that is not yet ready for commit, but we need to update our repository and Git won’t let you do that, without committing them (rebase will always give error) in such situation you use following set of commands</p>
<pre class="akcode">git stash

git svn rebase

git stash apply

git stash clear</pre>
<p>Update:</p>
<p>And if you don’t want to these things manually here is my favourite tool that does that using nice GUI and perfect windows integration <a href="http://code.google.com/p/tortoisegit/" target="_blank">TortoiseGit</a></p>
<p>I have written this a month back before I found TortoiseGit, so this is now just for reference, and to get me back to my blogging.</p>
<p>Have fun.</p>
<!-- WP Boastful Plugin by WPoets Team --> <div id='boastful'><strong></strong></div><hr style="border-top:black solid 1px" /><a href="http://amiworks.co.in/talk/how-to-use-svn-and-git-together-to-get-the-best-of-both-worlds-in-windows/">How to use SVN and Git together to get the best of both worlds in Windows</a> was first posted on August 17, 2009 at 3:51 pm.<br />©2008 "<a href="http://amiworks.co.in/talk">am i works?</a>". <br />]]></content:encoded>
			<wfw:commentRss>http://amiworks.co.in/talk/how-to-use-svn-and-git-together-to-get-the-best-of-both-worlds-in-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple JavaScript ‘Frame Busting’  Code</title>
		<link>http://amiworks.co.in/talk/simple-javascript-%e2%80%98frame-busting%e2%80%99-code/</link>
		<comments>http://amiworks.co.in/talk/simple-javascript-%e2%80%98frame-busting%e2%80%99-code/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 06:42:10 +0000</pubDate>
		<dc:creator>Amit Kumar Singh</dc:creator>
				<category><![CDATA[how too?]]></category>
		<category><![CDATA[frame busting]]></category>
		<category><![CDATA[iframe busting]]></category>
		<category><![CDATA[jail break]]></category>

		<guid isPermaLink="false">http://amiworks.co.in/talk/?p=287</guid>
		<description><![CDATA[Here is a quick JavaScript  code that you can use if you want to make sure that no one should be able to show your website in an IFrame. &#60;script type="text/javascript"&#62; if (top !=self) { top.location=self.location; } &#60;/script&#62; Just put this code in head section of your html page, and it will ensure that your [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a quick JavaScript  code that you can use if you want to make sure that no one should be able to show your website in an IFrame.</p>
<pre class="akcode">&lt;script type="text/javascript"&gt;
if (top !=self) {
   top.location=self.location;
}
&lt;/script&gt;</pre>
<p>Just put this code in head section of your html page, and it will ensure that your page always get’s displayed outside the frames.</p>
<!-- WP Boastful Plugin by WPoets Team --> <div id='boastful'><strong></strong></div><hr style="border-top:black solid 1px" /><a href="http://amiworks.co.in/talk/simple-javascript-%e2%80%98frame-busting%e2%80%99-code/">Simple JavaScript ‘Frame Busting’  Code</a> was first posted on April 16, 2009 at 12:12 pm.<br />©2008 "<a href="http://amiworks.co.in/talk">am i works?</a>". <br />]]></content:encoded>
			<wfw:commentRss>http://amiworks.co.in/talk/simple-javascript-%e2%80%98frame-busting%e2%80%99-code/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

