<?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>Mubarak Zeb&#039;s Blog</title>
	<atom:link href="http://blog.mzeb.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.mzeb.com</link>
	<description>PHP, MySQL, jQuery</description>
	<lastBuildDate>Wed, 09 Mar 2011 13:11:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Working at Peppercorn</title>
		<link>http://blog.mzeb.com/2011/03/09/working-at-peppercorn/</link>
		<comments>http://blog.mzeb.com/2011/03/09/working-at-peppercorn/#comments</comments>
		<pubDate>Wed, 09 Mar 2011 13:09:51 +0000</pubDate>
		<dc:creator>M.Zeb Khan</dc:creator>
				<category><![CDATA[Office / Job]]></category>

		<guid isPermaLink="false">http://blog.mzeb.com/?p=74</guid>
		<description><![CDATA[I have now joined Peppercorn Web Design company based in Bedford. It&#8217;s my second week, and I&#8217;m really enjoying working in this nice team.
]]></description>
			<content:encoded><![CDATA[<p>I have now joined <a href="http://www.peppercorn.co.uk">Peppercorn Web Design</a> company based in Bedford. It&#8217;s my second week, and I&#8217;m really enjoying working in this nice team.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mzeb.com/2011/03/09/working-at-peppercorn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xcode4 Preview 5 is here!</title>
		<link>http://blog.mzeb.com/2010/12/12/xcode4-preview-5-is-here/</link>
		<comments>http://blog.mzeb.com/2010/12/12/xcode4-preview-5-is-here/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 17:30:16 +0000</pubDate>
		<dc:creator>M.Zeb Khan</dc:creator>
				<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://blog.mzeb.com/?p=70</guid>
		<description><![CDATA[Apple has finally released Preview 5 of Xcode4. I am very excited and loving it, but it still has a few bugs and Apple recommends sticking to Xcode 3.2.5 if you want to develop apps for the app store. Few of the features that I love in Preview 5:

Many performance problems with making connections are [...]]]></description>
			<content:encoded><![CDATA[<p>Apple has finally released Preview 5 of Xcode4. I am very excited and loving it, but it still has a few bugs and Apple recommends sticking to Xcode 3.2.5 if you want to develop apps for the app store. Few of the features that I love in Preview 5:</p>
<ul>
<li>Many performance problems with making connections are resolved. In particular, the performance of connecting to the First Responder has been drastically improved.</li>
<li>C++: Several bugs related to using blocks are fixed.</li>
<li>Xcode automatically creates schemes for all targets in a project when you open an Xcode 3.x– based project. It doesn’t skip targets that other targets depend on.</li>
<li>When you create NSManagedObject subclasses from entities in a Core Data data model, Xcode ask for confirmation before overwriting existing files.</li>
</ul>
<p>Can&#8217;t wait for the Xcode4 final version! I am working on a nice app which is to be released in early February, and would love if Xcode4 is here by that time.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mzeb.com/2010/12/12/xcode4-preview-5-is-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Best approach to avoid MySQL injection.</title>
		<link>http://blog.mzeb.com/2010/12/12/best-approach-to-avoid-mysql-injection/</link>
		<comments>http://blog.mzeb.com/2010/12/12/best-approach-to-avoid-mysql-injection/#comments</comments>
		<pubDate>Sun, 12 Dec 2010 12:37:25 +0000</pubDate>
		<dc:creator>M.Zeb Khan</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.mzeb.com/?p=63</guid>
		<description><![CDATA[I was working in an open source script called PHPProBid. I decided to check what approach they are using to avoid MySQL injection, after looking into their source code I found out they were using the oldest method of escaping user inputted data using the mysql_real_escape_string(). And, it&#8217;s not just this script who uses this [...]]]></description>
			<content:encoded><![CDATA[<p>I was working in an open source script called PHPProBid. I decided to check what approach they are using to avoid MySQL injection, after looking into their source code I found out they were using the oldest method of escaping user inputted data using the <a href="http://www.php.net/mysql_real_escape_string">mysql_real_escape_string</a>(). And, it&#8217;s not just this script who uses this old method but in fact so many PHP tutorial websites still propagate the old methods and still don&#8217;t know the best approach which should be used to avoid MySQL injection. They don&#8217;t know that PHP&#8217;s manual itself discourages the use of such methods, and encourages to use advance methods such as PDO&#8217;s prepared statements.<span id="more-63"></span></p>
<p>Let&#8217;s have a look how prepared statements works in PHP, for example we are retrieving a user from the users table, the user id is passed using the query string ($_GET) which is very dangerous if passed to the database directly without filtering it. Below is the code to prepare the statement (bind the parameters) and then execute the statement. Assume we have the PDO object assigned to the variable $db:</p>
<pre class="brush:php">$stmt = $db-&gt;prepare("SELECT * FROM users WHERE user_id = ? ");
$stmt-&gt;bindParam(1,$_GET['user_id']);
$stmt-&gt;execute();
$results = $stmt-&gt;fetchAll(PDO::FETCH_OBJ);

// We can loop through the results nicely, like:
foreach($results as $row) {
   echo "{$row-&gt;username}&lt;br&gt;";
}

// Want to use the same statement with another User ID? no need to write more code do it like:
$stmt-&gt;bindParam(1,$_GET['another_user_id']);
$stmt-&gt;execute();
$results = $stmt-&gt;fetchAll(PDO::FETCH_OBJ);
</pre>
<p>Using the above method we are fully secure from a MySQL injection attack as the user input is filtered using a very advance method. Avoiding MySQL injection is not the only benefit of using prepared statements but there are so many benefits such as re-using the above statement more than once in our code.</p>
<p>Thanks for reading <img src='http://blog.mzeb.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mzeb.com/2010/12/12/best-approach-to-avoid-mysql-injection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iDXBall in the app store.</title>
		<link>http://blog.mzeb.com/2010/10/18/idxball-in-the-app-store/</link>
		<comments>http://blog.mzeb.com/2010/10/18/idxball-in-the-app-store/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 06:31:03 +0000</pubDate>
		<dc:creator>M.Zeb Khan</dc:creator>
				<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://blog.mzeb.com/?p=60</guid>
		<description><![CDATA[One of my game developed for iPhone, iPod touch and iPad has been accepted in the apple app store. Please download it and enjoy, visit the iDXBall website or View it in the app store
]]></description>
			<content:encoded><![CDATA[<p>One of my game developed for iPhone, iPod touch and iPad has been accepted in the apple app store. Please download it and enjoy, <a href="http://www.idxball.com">visit the iDXBall website</a> or <a href="http://itunes.apple.com/us/app/idxball/id397145997?mt=8">View it in the app store</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mzeb.com/2010/10/18/idxball-in-the-app-store/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m loving XCode 4.</title>
		<link>http://blog.mzeb.com/2010/10/08/im-loving-xcode-4/</link>
		<comments>http://blog.mzeb.com/2010/10/08/im-loving-xcode-4/#comments</comments>
		<pubDate>Fri, 08 Oct 2010 14:19:21 +0000</pubDate>
		<dc:creator>M.Zeb Khan</dc:creator>
				<category><![CDATA[iPhone Development]]></category>

		<guid isPermaLink="false">http://blog.mzeb.com/?p=55</guid>
		<description><![CDATA[I&#8217;ve just downloaded XCode 4 Preview3, I like so much that I wish I code all the day in Xcode. The code completion is improved by much, and the most important thing, the Interface Builder is now inside Xcode and you don&#8217;t need to open extra windows to manage your views in Interface Builder. I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just downloaded XCode 4 Preview3, I like so much that I wish I code all the day in Xcode. The code completion is improved by much, and the most important thing, the Interface Builder is now inside Xcode and you don&#8217;t need to open extra windows to manage your views in Interface Builder. I can&#8217;t wait to post a screenshot on my blog <img src='http://blog.mzeb.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> !<br />

<a href='http://blog.mzeb.com/2010/10/08/im-loving-xcode-4/screenshot-2010-10-08-at-15-17-48/' title='Screenshot 2010-10-08 at 15.17.48'><img width="150" height="150" src="http://blog.mzeb.com/wp-content/uploads/2010/10/Screenshot-2010-10-08-at-15.17.48-150x150.png" class="attachment-thumbnail" alt="" title="Screenshot 2010-10-08 at 15.17.48" /></a>
<a href='http://blog.mzeb.com/2010/10/08/im-loving-xcode-4/screenshot-2010-10-08-at-15-18-31/' title='Screenshot 2010-10-08 at 15.18.31'><img width="150" height="150" src="http://blog.mzeb.com/wp-content/uploads/2010/10/Screenshot-2010-10-08-at-15.18.31-150x150.png" class="attachment-thumbnail" alt="" title="Screenshot 2010-10-08 at 15.18.31" /></a>
</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mzeb.com/2010/10/08/im-loving-xcode-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Google Search Ajax&#8217;ed!</title>
		<link>http://blog.mzeb.com/2010/09/12/google-search-ajaxed/</link>
		<comments>http://blog.mzeb.com/2010/09/12/google-search-ajaxed/#comments</comments>
		<pubDate>Sun, 12 Sep 2010 22:28:31 +0000</pubDate>
		<dc:creator>M.Zeb Khan</dc:creator>
				<category><![CDATA[Google]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://blog.mzeb.com/?p=52</guid>
		<description><![CDATA[I was just googling for something and just saw google search results are now using Ajax. Keep it up google  
]]></description>
			<content:encoded><![CDATA[<p>I was just googling for something and just saw google search results are now using Ajax. Keep it up google <img src='http://blog.mzeb.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mzeb.com/2010/09/12/google-search-ajaxed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loop through list items of an unordered list using jQuery.</title>
		<link>http://blog.mzeb.com/2010/06/17/loop-through-list-items-of-an-unordered-list-using-jquery/</link>
		<comments>http://blog.mzeb.com/2010/06/17/loop-through-list-items-of-an-unordered-list-using-jquery/#comments</comments>
		<pubDate>Thu, 17 Jun 2010 14:17:50 +0000</pubDate>
		<dc:creator>M.Zeb Khan</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[javascript loop]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jquery .each()]]></category>

		<guid isPermaLink="false">http://blog.mzeb.com/?p=41</guid>
		<description><![CDATA[Suppose you have an unordered list with so many list items and you want to call a JavaScript function for each list item, the days are gone when you would put an onlick() attribute for each list item, we can now perform a loop on list items without even touching them!
Here is our unordered list [...]]]></description>
			<content:encoded><![CDATA[<p>Suppose you have an unordered list with so many list items and you want to call a JavaScript function for each list item, the days are gone when you would put an onlick() attribute for each list item, we can now perform a loop on list items without even touching them!</p>
<p>Here is our unordered list with list items:</p>
<pre class="brush:html">
<ul id="menu">
<li id="item1">My List Item 1</li>
<li id="item2">My List Item 2</li>
<li id="item3">My List Item 3</li>
<li id="item4">My List Item 4</li>
</ul>
</pre>
<p>Now let&#8217;s loop through the list and show an alert with the id of each item. Below is the Javascript code to achieve our goal, please note you must include jquery library in your page&#8217;s <strong>&lt;head&gt;</strong> tag for the script to work:</p>
<pre class="brush:js">
$('#menu li').each(function() {

   alert(this.id);

});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.mzeb.com/2010/06/17/loop-through-list-items-of-an-unordered-list-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Make an array have same keys as values.</title>
		<link>http://blog.mzeb.com/2010/06/16/make-an-array-have-same-keys-as-values/</link>
		<comments>http://blog.mzeb.com/2010/06/16/make-an-array-have-same-keys-as-values/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 01:34:14 +0000</pubDate>
		<dc:creator>M.Zeb Khan</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.mzeb.com/?p=39</guid>
		<description><![CDATA[Have you ever wanted to make an array with same keys as the values? for example, we want an array of fruits.
$my_array = array('apple','orange','mango');

By default, when you don&#8217;t specify a key for each array element a default numeric key is assigned, the above be assigned key indexes as:
Array
(
   [0] =&#62; apple
   [...]]]></description>
			<content:encoded><![CDATA[<p>Have you ever wanted to make an array with same keys as the values? for example, we want an array of fruits.</p>
<pre class="brush:php">$my_array = array('apple','orange','mango');
</pre>
<p>By default, when you don&#8217;t specify a key for each array element a default numeric key is assigned, the above be assigned key indexes as:</p>
<pre class="brush:php">Array
(
   [0] =&gt; apple
   [1] =&gt; orange
   [2] =&gt; mango
)
</pre>
<p>But that&#8217;s not actually what you want right? thanks to the built in PHP array function <a href="http://php.net/array_combine">array_combine()</a> we can combine the array values with the keys. Let&#8217;s try the following</p>
<pre class="brush:php">
$my_array = array('apple','orange','mango');
$my_array = array_combine($my_array,$my_array);
</pre>
<p>Now, let&#8217;s run a <a href="http://php.net/print_r">print_r($my_array)</a> to see how it looks, the results will be:</p>
<pre class="brush:php">Array
(
   [apple] =&gt; apple
   [orange] =&gt; orange
   [mango] =&gt; mango
)
</pre>
<p>There we go! you can use this idea if you have a country list array with short country name for the array key, this happened to me when I had a country list array where the key for country <strong>Canada</strong> was <strong>CA</strong>. I just used array_combine() and everything worked like a charm!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mzeb.com/2010/06/16/make-an-array-have-same-keys-as-values/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Stripping slashes in Zend Framework.</title>
		<link>http://blog.mzeb.com/2010/06/12/stripping-slashes-in-zend-framework/</link>
		<comments>http://blog.mzeb.com/2010/06/12/stripping-slashes-in-zend-framework/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 16:52:27 +0000</pubDate>
		<dc:creator>M.Zeb Khan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[stripslashes]]></category>
		<category><![CDATA[stripslashes zend framework]]></category>

		<guid isPermaLink="false">http://blog.mzeb.com/?p=35</guid>
		<description><![CDATA[By default Zend Framework will escape data passed to the insert() method, For example if you have a textarea in your form that is accepting input from the user, and someone writes something like I&#8217;m testing this form, this will be inserted to the database as I\&#8217;m testing this form. We have a built-in function [...]]]></description>
			<content:encoded><![CDATA[<p>By default Zend Framework will escape data passed to the insert() method, For example if you have a textarea in your form that is accepting input from the user, and someone writes something like<strong> I&#8217;m testing this form</strong>, this will be inserted to the database as <strong>I\&#8217;m testing this form. </strong>We have a built-in function in PHP called stripslashes() that will strip the slashes from the record, but how about if you&#8217;re populating the form fields using the $form-&gt;populate() ? the best solution is use the setEscape() inside the controller&#8217;s init() method. Let&#8217;s try it,</p>
<pre class="brush:php">public function init() {
    $this-&gt;view-&gt;setEscape('stripslashes');
}
</pre>
<p>This will strip all the slashes from the view.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mzeb.com/2010/06/12/stripping-slashes-in-zend-framework/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Planning to take the Zend PHP5 Certification.</title>
		<link>http://blog.mzeb.com/2010/06/12/planning-to-take-the-zend-php5-certification/</link>
		<comments>http://blog.mzeb.com/2010/06/12/planning-to-take-the-zend-php5-certification/#comments</comments>
		<pubDate>Sat, 12 Jun 2010 15:08:00 +0000</pubDate>
		<dc:creator>M.Zeb Khan</dc:creator>
				<category><![CDATA[Zend PHP5 Certification]]></category>

		<guid isPermaLink="false">http://blog.mzeb.com/?p=31</guid>
		<description><![CDATA[I&#8217;m planning to take the Zend PHP5 Certification next month, I have been PHP Programming since 2004, but I still need to improve my weak areas such as PHP Patterns, Regular Expressions and XML/Web Services etc. Thanks to my best friend Wajid Khan for giving me the PHP Anthology book, I consider this the best [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m planning to take the Zend PHP5 Certification next month, I have been PHP Programming since 2004, but I still need to improve my weak areas such as PHP Patterns, Regular Expressions and XML/Web Services etc. Thanks to my best friend Wajid Khan for giving me the PHP Anthology book, I consider this the best book ever written about PHP, the 101 Essential Tips, tricks and hacks mentioned in this book are really useful.</p>
<p>I will keep posting my experience regarding my preparation for the exam.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.mzeb.com/2010/06/12/planning-to-take-the-zend-php5-certification/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

