<?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>ZENVERSE &#187; Web Development</title>
	<atom:link href="http://zenverse.net/category/web-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://zenverse.net</link>
	<description>Design and Web Development</description>
	<lastBuildDate>Sun, 13 May 2012 15:26:20 +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>Fixing Javascript Error: Property &#8216;submit&#8217; of object #&lt;HTMLFormElement&gt; is not a function</title>
		<link>http://zenverse.net/js-property-submit-of-object-htmlformelement-is-not-function/</link>
		<comments>http://zenverse.net/js-property-submit-of-object-htmlformelement-is-not-function/#comments</comments>
		<pubDate>Sun, 01 Apr 2012 09:55:25 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2499</guid>
		<description><![CDATA[If you come across this error when you code your javascript, most probably you are trying to submit the form dynamically using javascript. Don't worry, the solution is easy.]]></description>
			<content:encoded><![CDATA[<blockquote><p>Property &#8216;submit&#8217; of object #<HTMLFormElement> is not a function</p></blockquote>
<p>If you come across this error in javascript, most probably you are trying to submit the form dynamically using javascript. Don&#8217;t worry, the solution is easy.</p>
<h3>The Solution</h3>
<p>Check your &lt;form> element. It MUST not have any HTML element with ID attribute of &#8220;submit&#8221;.<br />
If you have such element, rename the ID attribute to some other name.</p>
<h3>Explanation</h3>
<p>Let&#8217;s say if your form element has a button with ID &#8220;submit&#8221;. When you trigger yourform.submit(), your browser actually tries to run your button element as a function instead of running the form&#8217;s submit function. </p>
<p>Hope this helps. Please &#8220;Like&#8221; this post if it works for you :)</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/js-property-submit-of-object-htmlformelement-is-not-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to Remove Facebook Cache of Your Page&#8217;s Metadata</title>
		<link>http://zenverse.net/remove-facebook-cache-of-your-page-matadata/</link>
		<comments>http://zenverse.net/remove-facebook-cache-of-your-page-matadata/#comments</comments>
		<pubDate>Sun, 04 Mar 2012 14:14:21 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2506</guid>
		<description><![CDATA[Whenever Facebook visited a page (most probably when someone shared your URL on Facebook), your page's metadata will be cached. I am not sure when the cache expires, but you can actually clear the cache easily by directing your browser to this address below]]></description>
			<content:encoded><![CDATA[<p>Whenever Facebook visited a page (most probably when someone shared your URL on Facebook), your page&#8217;s metadata will be cached. I am not sure when the cache expires, but you can actually clear the cache easily by directing your browser to this address below:</p>
<blockquote><p>http://developers.facebook.com/tools/debug/og/object?q=[YOUR_PAGE_URL]&#038;fbrefresh=any</p></blockquote>
<p>Of course, replace &#8220;[YOUR_PAGE_URL]&#8221; with your page URL and you are good to go.</p>
<p>I also created a quick page for you to <a href="http://tools.zenverse.net/clear-facebook-cache/" title="Clear Facebook Cache Metadata" target="_blank">clear facebook cache of any page</a> in my WebTools Site. You can bookmark this page to use it in future.</p>
<p>Hope this helps :)</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/remove-facebook-cache-of-your-page-matadata/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reducing Image File Size (Compression) using PHP GD</title>
		<link>http://zenverse.net/php-reducing-image-filesize-using-gd/</link>
		<comments>http://zenverse.net/php-reducing-image-filesize-using-gd/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 09:11:23 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2478</guid>
		<description><![CDATA[Most of the time, photos uploaded by users are not optimized for web. In other words, they might not be using the best file format for their photos, thus taking much more spaces in your server than it actually need. Using PHP, you can easily reduce the file size of those uploaded images during upload time.  But of course, when reducing the file size, we sacrifice the image quality. Therefore, if you are running image uploader website, this is not recommended.]]></description>
			<content:encoded><![CDATA[<p>Most of the time, photos uploaded by users are not optimized for web. In other words, they might not be using the best file format for their photos, thus taking much more spaces in your server than it actually need. Using PHP, you can easily reduce the file size of those uploaded images during upload time. But of course, when reducing the file size, we sacrifice the image quality. Therefore, if you are running image uploader website, this is not recommended.</p>
<h3>The simple function</h3>
<p>The best file format for photo is JPEG as it provides the best reduction in file size. The downside is losing details &#8211; your photo will be blurred depending on your quality setting. If your photo contains crisp texts, the text will most likely be blurred. Check out the code below.</p>
<p>This function below can load from PNG, JPEG or GIF file ($source_url) and save the compressed photo as JPEG in $destination_url.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2478code1'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24781"><td class="code" id="p2478code1"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> compress_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$quality</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$info</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/getimagesize"><span style="color: #990000;">getimagesize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/jpeg'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefromjpeg"><span style="color: #990000;">imagecreatefromjpeg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/gif'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefromgif"><span style="color: #990000;">imagecreatefromgif</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/png'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefrompng"><span style="color: #990000;">imagecreatefrompng</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//save file</span>
	<a href="http://www.php.net/imagejpeg"><span style="color: #990000;">imagejpeg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$quality</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//return destination file</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//usage</span>
<span style="color: #000088;">$compressed</span> <span style="color: #339933;">=</span> compress_image<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'source.png'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'destination.jpg'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p><b>Explanation</b></p>
<ul>
<li>imagecreatefromjpeg() is where PHP loads your source image.</li>
<li>imagejpeg() is the part where PHP output the image. In our case, we specified the second parameter (destination_url) therefore PHP saved the image instead of outputting it.</li>
<li>You can control the quality of the image. In the example above, we used 90/100 to maintain the quality of the photo while reducing file size. You need to try out various setting to suit your need.</li>
<h3>A quick testing page</h3>
<p>I have written a small PHP page to test the image compression. It put your original and compressed photos side by side so that you can compare the quality and file size. Save it as compress.php, change the image URL and quality setting then run it in your server.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2478code2'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24782"><td class="code" id="p2478code2"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> compress_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$quality</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$info</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/getimagesize"><span style="color: #990000;">getimagesize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/jpeg'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefromjpeg"><span style="color: #990000;">imagecreatefromjpeg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/gif'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefromgif"><span style="color: #990000;">imagecreatefromgif</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$info</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'mime'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'image/png'</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$image</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/imagecreatefrompng"><span style="color: #990000;">imagecreatefrompng</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//save it</span>
	<a href="http://www.php.net/imagejpeg"><span style="color: #990000;">imagejpeg</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$image</span><span style="color: #339933;">,</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">,</span> <span style="color: #000088;">$quality</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">//return destination file url</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$destination_url</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$source_photo</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'uploads/source.jpg'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dest_photo</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'uploads/testing.jpg'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$d</span> <span style="color: #339933;">=</span> compress_image<span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_photo</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dest_photo</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'
&lt;div style=&quot;float:left;margin-right:10px&quot;&gt;
	&lt;img src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$source_photo</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; alt=&quot;&quot; /&gt;
	&lt;br /&gt;'</span><span style="color: #339933;">.</span><a href="http://www.php.net/filesize"><span style="color: #990000;">filesize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source_photo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' Bytes
&lt;/div&gt;
&nbsp;
&lt;div style=&quot;float:left;&quot;&gt;
	&lt;img src=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$dest_photo</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; alt=&quot;&quot; /&gt;
	&lt;br /&gt;'</span><span style="color: #339933;">.</span><a href="http://www.php.net/filesize"><span style="color: #990000;">filesize</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dest_photo</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' Bytes
&lt;/div&gt;
'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Hope this helps :)</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-reducing-image-filesize-using-gd/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Using oEmbed API to Embed Videos</title>
		<link>http://zenverse.net/php-oembed-embed-videos/</link>
		<comments>http://zenverse.net/php-oembed-embed-videos/#comments</comments>
		<pubDate>Mon, 30 Jan 2012 08:53:09 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2445</guid>
		<description><![CDATA[oEmbed is a format for allowing an embedded representation of a URL on third party sites. Which means, if we have a video page's URL, we can easily get the video thumbnail photo, video title, HTML code to embed it in our website and more. But of course, the video site must have oEmbed support in order for us to do that.]]></description>
			<content:encoded><![CDATA[<p>oEmbed is a format for allowing an embedded representation of a URL on third party sites. Which means, if we have a video page&#8217;s URL, we can easily get the video thumbnail photo, video title, HTML code to embed it in our website and more. But of course, the video site must have oEmbed support in order for us to do that. Check out <a rel="nofollow" target="_blank" href="http://oembed.com">http://oembed.com</a> for full documentation.</p>
<h3>Let&#8217;s look at how YouTube oEmbed works</h3>
<p>1. First, send a request to YouTube&#8217;s Oembed API page with a video URL (must be urlencoded) as parameter and we also specified that we want it to be returned in json format.</p>
<blockquote><p><a rel="nofollow" target="_blank" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json</a>
</p></blockquote>
<p>2. You will then see a long json-encoded string which contains all information about the video.</p>
<p>3. Next thing you need to do is just simply json-decode the string using your programming language, then you are free to use the information. We will see how to do that in PHP.</p>
<h3>Using Oembed to Embed Youtube Videos in PHP</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2445code3'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24453"><td class="code" id="p2445code3"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$videourl</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http://www.youtube.com/watch?v=gB4nwqNM190'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$json</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><a href="http://www.php.net/file_get_contents"><span style="color: #990000;">file_get_contents</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'http://www.youtube.com/oembed?url='</span><span style="color: #339933;">.</span><a href="http://www.php.net/urlencode"><span style="color: #990000;">urlencode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$videourl</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;format=json'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$decode</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/json_decode"><span style="color: #990000;">json_decode</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$json</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$decode</span> <span style="color: #339933;">==</span> <span style="color: #009900; font-weight: bold;">null</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #000088;">$decode</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$error</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//error control here</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$thumb</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$decode</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'thumbnail_url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$html</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$decode</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'html'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>It&#8217;s pretty straightforward and self-explanatory:</p>
<ul>
<li>First, we send a url request to YouTube&#8217;s obembed API page using file_get_contents() function.</li>
<li>Second, we decode the response using json_decode() function which convert json format to array.</li>
<li>Third, if there is no error in decoding, we then assign $thumb and $html and use it in our website or program.</li>
</ul>
<h3>Extra: If you want to limit the embedded video&#8217;s width or height</h3>
<p>You can specify the max height or max width by appending the maxwidth or maxheight parameters to the oembed URL. (Please note that this cannot resize a smaller video to bigger size)</p>
<p>For example, from our example above, to specify max width of 300 pixels:</p>
<blockquote><p><a rel="nofollow" target="_blank" href="http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json&#038;maxwidth=300">http://www.youtube.com/oembed?url=http%3A//www.youtube.com/watch%3Fv%3DbDOYN-6gdRE&#038;format=json&#038;maxwidth=300</a></p></blockquote>
<p>You should notice the video embedding code (iframe) is now limited to width of 300 pixels.</p>
<h3>How do I embed videos from other video sites like Vimeo?</h3>
<p>Most of the popular video sites has oEmbed support just like YouTube. For example, by <a target="_blank" href="http://www.google.com/search?q=vimeo+oembed">googling &#8220;vimeo oembed&#8221;</a> we found vimeo oembed documentation.</p>
<p>In vimeo, this is the URL we should send our request to:</p>
<blockquote><p><a rel="nofollow" href="http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/7100569" target="_blank">http://vimeo.com/api/oembed.json?url=http%3A//vimeo.com/7100569</a></p></blockquote>
<p>More details about oEmbed API page for other video sites will be covered in our next blog post (coming soon).</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-oembed-embed-videos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP MySQL &#8211; Get Next Auto Increment Value of a Table</title>
		<link>http://zenverse.net/php-mysql-next-auto-increment-value/</link>
		<comments>http://zenverse.net/php-mysql-next-auto-increment-value/#comments</comments>
		<pubDate>Sat, 14 Jan 2012 06:05:14 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2404</guid>
		<description><![CDATA[We do not often need this but sometimes when we need to retrieve the next auto increment value of a table (without incrementing the auto increment value of course), this solution below will help.]]></description>
			<content:encoded><![CDATA[<p>We do not often need this but sometimes when we need to retrieve the next auto increment value of a table (without incrementing the auto increment value of course), this solution below will help.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2404code4'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24044"><td class="code" id="p2404code4"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHOW TABLE STATUS WHERE name='your_table_name_here'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span style="color: #990000;">mysql_num_rows</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Auto_increment'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//error</span>
	<span style="color: #666666; font-style: italic;">//error control here</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Just replace &#8220;your_table_name_here&#8221; with your mySQL table name.</p>
<h3>As a Function</h3>
<p>Furthermore, making it a PHP function would make the solution looks clean.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2404code5'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p24045"><td class="code" id="p2404code5"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> get_next_value<span style="color: #009900;">&#40;</span><span style="color: #000088;">$tablename</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_query"><span style="color: #990000;">mysql_query</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHOW TABLE STATUS WHERE name='&quot;</span><span style="color: #339933;">.</span><a href="http://www.php.net/mysql_real_escape_string"><span style="color: #990000;">mysql_real_escape_string</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$tablename</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/mysql_num_rows"><span style="color: #990000;">mysql_num_rows</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/mysql_fetch_assoc"><span style="color: #990000;">mysql_fetch_assoc</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$query</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Auto_increment'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//error</span>
		<span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//usage</span>
<span style="color: #000088;">$nextval</span> <span style="color: #339933;">=</span> get_next_value<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'your_table_name_here'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-mysql-next-auto-increment-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Smart Date Function &#8211; Display Time Elapsed (Difference) Based on a Given Timestamp</title>
		<link>http://zenverse.net/php-smart-date-function/</link>
		<comments>http://zenverse.net/php-smart-date-function/#comments</comments>
		<pubDate>Mon, 12 Dec 2011 04:43:29 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2371</guid>
		<description><![CDATA[As a web developer, we often need to display dates in our website. As a web user myself, I don't like to read full dates like "26 November 2011 11:30PM" because it takes me a little while to interpret the date. I prefer reading smart dates like "1 hour ago" or "6 months ago". Therefore, here I wrote a quick and simple function in PHP that display the time difference/elapsed based on a given timestamp value.]]></description>
			<content:encoded><![CDATA[<p>As a web developer, we often need to display dates in our website. As a web user myself, I don&#8217;t like to read full dates like &#8220;26 November 2011 11:30PM&#8221; because it takes me a little while to interpret the date. I prefer reading smart dates like &#8220;1 hour ago&#8221; or &#8220;6 months ago&#8221;. Therefore, here I wrote a quick and simple function in PHP that display the time difference/elapsed based on a given timestamp value.</p>
<h3>PHP Smart Date Function</h3>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2371code6'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23716"><td class="code" id="p2371code6"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">/*
Simple PHP Smart Date Function
by Zen (http://zenverse.net)
*/</span>
<span style="color: #000000; font-weight: bold;">function</span> smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$timestamp</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$diff</span> <span style="color: #339933;">=</span> <a href="http://www.php.net/time"><span style="color: #990000;">time</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #000088;">$timestamp</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #0000ff;">'Now'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' second(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' minute(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' hour(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' day(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span> <span style="color: #339933;">&lt;</span> <span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' month(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> grammar_date<span style="color: #009900;">&#40;</span><a href="http://www.php.net/floor"><span style="color: #990000;">floor</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$diff</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">60</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">24</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">30</span><span style="color: #339933;">*</span><span style="color: #cc66cc;">12</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">' year(s) ago'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> grammar_date<span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sentence</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$val</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$val</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'(s)'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'s'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sentence</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$val</span><span style="color: #339933;">.</span><a href="http://www.php.net/str_replace"><span style="color: #990000;">str_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'(s)'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sentence</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Basically I defined 2 functions above:<br />
<strong>smartdate</strong> &#8211; calculates the difference between given timestamp and current time, then returns the correct sentence<br />
<strong>grammar_date</strong> &#8211; modifies the returned sentence to plural form or singular form</p>
<h3>Usage</h3>
<p>The usage is simple and straightforward.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2371code7'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23717"><td class="code" id="p2371code7"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//example 1</span>
<span style="color: #b1b100;">echo</span> smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$yourtimestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//example 2</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Posted on '</span><span style="color: #339933;">.</span>smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$yourtimestamp</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>By default, this function returns the floor() value, i.e: instead of returning &#8220;1.7 years ago&#8221;, it returns &#8220;1 year ago&#8221;. Anyway, the function can be easily modified to suit your specific needs.</p>
<h3>Give users the choice to view the full date</h3>
<p>1 disadvantage of smart date is of course, it reduces the level of detail and granularity of the date information. For example, dates of 13 months ago or 19 months ago will both be displayed as &#8220;1 year ago&#8221;.</p>
<p>The most common way to let user view the full date is to add a &#8220;title&#8221; attribute with full date as the attribute value. Now, when user mouseover your smart date, they can see the full date popping up as tooltip. Facebook uses this approach.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2371code8'); return false;">View Code</a> PHP</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23718"><td class="code" id="p2371code8"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//from example 2 above</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Posted on &lt;span title=&quot;'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$originalfulldate</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&quot;&gt;'</span> <span style="color: #339933;">.</span> smartdate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$yourtimestamp</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&lt;/span&gt;'</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/php-smart-date-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cannot Access Localhost After Editing etc/hosts and Flushing DNS Cache</title>
		<link>http://zenverse.net/cannot-access-localhost-after-editing-etchosts-flush-cache/</link>
		<comments>http://zenverse.net/cannot-access-localhost-after-editing-etchosts-flush-cache/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 16:23:42 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mac]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2354</guid>
		<description><![CDATA[I was developing a new website that uses Facebook Login as the membership system. I came across this situation where I needed to create a "fake" domain by editing the etc/hosts file. Somehow, after editing the etc/hosts file (following an online guide), I cannot seems to browse http://localhost in my browser anymore. However, I can still browse my local apache server using http://127.0.0.1]]></description>
			<content:encoded><![CDATA[<p>I was developing a new website that uses Facebook Login as the membership system. I came across this situation where I needed to create a &#8220;fake&#8221; domain by editing the etc/hosts file. Somehow, after editing the etc/hosts file (following an online guide), I cannot seems to browse http://localhost in my browser anymore. However, I can still browse my local apache server using http://127.0.0.1</p>
<blockquote><p><strong>NOTE:</strong><br />
This is not XAMPP / apache issue<br />
This is not browser-specific issue
</p></blockquote>
<p>In fact, this is a simple problem with simple solution. However, this problem occurs when I am getting frustrated with the Facebook integration problem (after 12 hours of debugging). Therefore, I missed some simple but important steps to solve this problem. Here I list them down below:</p>
<h3>1. Ping Localhost</h3>
<p>For Mac OS users, open up your Terminal. For windows users, open up your command prompt.</p>
<ul>
<li>Type the &#8220;ping localhost&#8221; and press enter.</li>
<li>You should get error messages like &#8220;unknown host&#8221; since you are having this problem.</li>
</ul>
<ul>
<li>Next, type &#8220;ping 127.0.0.1&#8243; and press enter.</li>
<li>If you saw something like this, the ping is successful:

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2354code9'); return false;">View Code</a> CMD</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p23549"><td class="code" id="p2354code9"><pre class="cmd" style="font-family:monospace;">PING 127.0.0.1 (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.118 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.171 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.167 ms</pre></td></tr></table></div>

</li>
<li>If you get &#8220;unknown host error&#8221;, please check whether you have started your local server service.</li>
</ul>
<h3>2. Clear your browser cache</h3>
<p>Modern browsers cache a lot of stuff, including DNS cache. They may have cached the erroneous DNS setting in etc/hosts, so you might want to clear your browsers cache and try loading localhost again. Clearing cache alone would already be sufficient, you can skip clearing cookies, saved session, etc.</p>
<p>If it still doesn&#8217;t work, try #3 below.</p>
<h3>3. Did you just flushed the DNS cache?</h3>
<p>I ran this command in terminal (Mac) to flush my cache before I get into this mess: &#8220;dscacheutil -flushcache&#8221;<br />
For some reason, after I flushed the cache, the DNS setting is not being rebuilt &#8211; I cannot ping localhost but I can ping 127.0.0.1</p>
<p>After restarting my laptop (to rebuild the DNS settings &#038; cache) and clearing all browser cache once again, I finally get my localhost displayed again.</p>
<p>Now I hope this helps some of you.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/cannot-access-localhost-after-editing-etchosts-flush-cache/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Legacy Facebook &#8220;Share&#8221; Button Codes (Bubble Count, Box Count and More)</title>
		<link>http://zenverse.net/legacy-facebook-share-button-code/</link>
		<comments>http://zenverse.net/legacy-facebook-share-button-code/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 16:12:32 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[facebook]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2329</guid>
		<description><![CDATA[Few months ago, Facebook removed the page that allow us to generate codes for their official "Share" button. They replaced it with <a href="https://developers.facebook.com/docs/reference/plugins/like" target="_blank">"Like" button</a> instead. While "Like" button is fast and easy but we cannot add our comment along with the "Like" action. Therefore, in some cases, we still need the old Share button. Fortunately, the sharer.php still exists, so we can add the Share button using Facebook's official script.]]></description>
			<content:encoded><![CDATA[<p>Few months ago, Facebook removed the page that allow us to generate codes for their official &#8220;Share&#8221; button. They replaced it with <a href="https://developers.facebook.com/docs/reference/plugins/like" target="_blank">&#8220;Like&#8221; button</a> instead. While &#8220;Like&#8221; button is fast and easy but we cannot add our comment along with the &#8220;Like&#8221; action. Therefore, in some cases, we still need the old Share button. Fortunately, the sharer.php still exists, so we can add the Share button using Facebook&#8217;s official script.</p>
<p>Here are the complete codes for all sizes of Facebook share button for those who are interested:</p>
<h3>Box Count</h3>
<p><a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a> &nbsp;*count will only visible when there is at least 1 share</p>
<div class="clear"></div>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code10'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232910"><td class="code" id="p2329code10"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;box_count&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Button Count</h3>
<p><a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a> *count will only visible when there is at least 1 share</p>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code11'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232911"><td class="code" id="p2329code11"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;button_count&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Button only</h3>
<p><a name="fb_share" type="button" href="http://www.facebook.com/sharer.php">Share</a></p>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code12'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232912"><td class="code" id="p2329code12"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;button&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Small Icon only</h3>
<p><a name="fb_share" type="icon" href="http://www.facebook.com/sharer.php">Share</a></p>
<p>Codes:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code13'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232913"><td class="code" id="p2329code13"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;icon&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Custom URL?</h3>
<p>All codes above &#8220;shares&#8221; the current page. If you want to share another page or a specific page, you need to add a &#8220;share_url&#8221; attribute to the &lt;a> tag. You need this too when you have multiple share buttons in a single page.</p>
<p>Example below shares our main website http://zenverse.net instead of this page.</p>
<p><a name="fb_share" type="button_count" share_url="http://zenverse.net" href="http://www.facebook.com/sharer.php">Share</a></p>
<p>Here&#8217;s how:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2329code14'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p232914"><td class="code" id="p2329code14"><pre class="html" style="font-family:monospace;">&lt;a name=&quot;fb_share&quot; type=&quot;button_count&quot; share_url=&quot;http://zenverse.net&quot; href=&quot;http://www.facebook.com/sharer.php&quot;&gt;Share&lt;/a&gt;
&lt;script src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<h3>Multiple Share Buttons</h3>
<p>If you have multiple share buttons in a single page, you just need to include the &lt;script> element <b>once</b>.</p>
<p>Hope this helps.</p>
<p><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/legacy-facebook-share-button-code/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>4 Must-Have Google Chrome Extensions for Web Developers</title>
		<link>http://zenverse.net/4-google-chrome-extensions-for-web-dev/</link>
		<comments>http://zenverse.net/4-google-chrome-extensions-for-web-dev/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 09:59:23 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Web Development]]></category>
		<category><![CDATA[chrome]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2201</guid>
		<description><![CDATA[Web developers often need to do repetitive works such as taking screenshots, turning off javascript or images, check backlinks or ranking of websites and more. Fortunately, with these 4 totally free Google Chrome extensions, web developers can save a lot of time on these repetitive works, thus increasing productivity.]]></description>
			<content:encoded><![CDATA[<p>Web developers often need to do repetitive works such as taking screenshots, turning off javascript or images, check backlinks or ranking of websites and more. Fortunately, with these 4 totally free Google Chrome extensions, web developers can save a lot of time on these repetitive works, thus increasing productivity.</p>
<h3><a rel="nofollow" target="_blank" href="https://chrome.google.com/webstore/detail/alelhddbbhepgpmgidjdcjakblofbmce">Awesome Screenshot: Capture &#038; Annotate</a></h3>
<p><a href="http://zenverse.net/wp-content/uploads/2011/09/screenshot.jpg"><img src="http://zenverse.net/wp-content/uploads/2011/09/screenshot.jpg" alt="" title="screenshot" width="260" height="147" class="alignnone size-full wp-image-2208" /></a></p>
<p>As the name suggests, this awesome extension can do more than just screenshot. At a glance, it provide 3 ways to capture screenshots: visible area, entire page or selected area. Furthermore, it allows us to crop, annotate the screenshot with shapes and texts as well as blur sensitive info. Most importantly, it comes with undo feature. </p>
<h3><a rel="nofollow" target="_blank" href="https://chrome.google.com/webstore/detail/gbkffbkamcejhkcaocmkdeiiccpmjfdi">Pendule</a></h3>
<p>This is an essential extension for web developers. Below are some key features of Pendule I find it useful:</p>
<p><a href="http://zenverse.net/wp-content/uploads/2011/09/pendule.jpg"><img src="http://zenverse.net/wp-content/uploads/2011/09/pendule.jpg" alt="" title="pendule" width="450" height="308" class="alignnone size-full wp-image-2207" /></a></p>
<ul>
<li>View all css and javascript codes with syntax highlighting</li>
<li>Reload css without refreshing the page.</li>
<li>One-click disable or enable external/inline CSS</li>
<li>One click hide all images / background images</li>
<li>Color picker and ruler to measure an element in pixels</li>
<li>Links to validate html / css / feed</li>
<li>Added &#8220;View Selection Source&#8221; feature (when you right click a highlighted area), just like in Mozilla Firefox.</li>
</ul>
<h3><a rel="nofollow" href="https://chrome.google.com/webstore/detail/idhfcdbheobinplaamokffboaccidbal" target="_blank">Resolution Test</a></h3>
<p><a href="http://zenverse.net/wp-content/uploads/2011/09/screensize.jpg"><img src="http://zenverse.net/wp-content/uploads/2011/09/screensize.jpg" alt="" title="screensize" width="253" height="227" class="alignnone size-full wp-image-2209" /></a></p>
<p>This allows web developers to test their website in all common screen resolutions, as well as user-defined size. With this extension, we do not have to update our screen resolution manually anymore. All common screen size can be applied and tested with only one click, Google Chrome will then changed its windows size, without changing the screen resolution.</p>
<h3><a rel="nofollow" href="https://chrome.google.com/webstore/detail/oangcciaeihlfmhppegpdceadpfaoclj" target="_blank">SEO for Chrome</a></h3>
<p><a href="http://zenverse.net/wp-content/uploads/2011/09/seochrome.jpg"><img src="http://zenverse.net/wp-content/uploads/2011/09/seochrome.jpg" alt="" title="seochrome" width="524" height="310" class="alignnone size-full wp-image-2210" /></a></p>
<p>This extension can display information such as page rank, number of backlinks, social media stats, traffic stats and more within seconds. It can also show all nofollow links, if enabled, by highlighting them with border. The keyword research tool sounds useful too, although I can&#8217;t seems to use it at the moment.</p>
<p>If you know other good extension, feel free to share with us in the comment section.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/4-google-chrome-extensions-for-web-dev/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to Fix FTP Login Problem in WordPress in XAMPP for Mac OS (Localhost)</title>
		<link>http://zenverse.net/wordpress-ftp-login-problem-xampp-mac-localhost/</link>
		<comments>http://zenverse.net/wordpress-ftp-login-problem-xampp-mac-localhost/#comments</comments>
		<pubDate>Tue, 12 Jul 2011 15:44:29 +0000</pubDate>
		<dc:creator>Zen</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[xampp]]></category>

		<guid isPermaLink="false">http://zenverse.net/?p=2047</guid>
		<description><![CDATA[If you are using XAMPP for Mac OS like me, and was asked to enter FTP login information when you upgrade Wordpress core and download themes or plugins, then this guide is for you. After searching for solution online, I found that this is a permission problem due to your Mac's username is different compared to the default user name in XAMPP for Mac, called nobody.]]></description>
			<content:encoded><![CDATA[<p>If you are using XAMPP for Mac OS like me, and was asked to enter FTP login information when you upgrade WordPress core and download themes or plugins, then this guide is for you. After searching for solution online, I found that this is a permission problem due to your Mac&#8217;s username is different compared to the default user name in XAMPP for Mac, called nobody.</p>
<p>As far as I understand, this has nothing to do with FTP settings. This problem occurs because the Apache HTTP service was being run as &#8220;nobody&#8221; while your Mac user name is a different name. Thus, it has no permission to add/edit your server files so WordPress attempted to use FTP to perform its job.</p>
<h3>Editing httpd.conf as Admin</h3>
<p>First of all, editing this file is not as easy as using a text editor program and edit it because this read-only file can only be changed by root or superuser, not even administrator. There are 2 or more methods that you use to edit such file:</p>
<blockquote><p>1. Edit using vi editor in sudo mode using Terminal<br />
<strong>2. Run Mac OS TextEditor in sudo mode using Terminal and edit the file</strong></p></blockquote>
<p>- Terminal is a command line tool just like Window&#8217;s CMD.<br />
- Sudo mode refers to running the file as superuser or root.<br />
- Vi editor is a command line editor that is very not user-friendly to use, edit and save (at least for beginner)</p>
<p>Thus we will use Method 2 to perform this task.</p>
<h3>1. Run Mac OS TextEditor application in sudo mode using Terminal and edit the file</h3>
<p>First of all, open up your Terminal by typing &#8220;Terminal&#8221; in your Spotlight search box (upper right corner)</p>
<p>Once the terminal is loaded, type this in: (copy and paste if possible)</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2047code15'); return false;">View Code</a> TERMINAL</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p204715"><td class="code" id="p2047code15"><pre class="terminal" style="font-family:monospace;">sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /Applications/XAMPP/etc/httpd.conf</pre></td></tr></table></div>

<p>- sudo command will run the TextEdit application as root<br />
- Seperated by a space after the application path, is the path of httpd.conf (the file to edit)</p>
<p>Press enter, a TextEdit window should pop up and you can then freely edit the file as root.</p>
<h3>2. Change the user name and group name</h3>
<p>Now, look for these 2 lines:</p>
<blockquote><p>User nobody<br />
Group admin</p></blockquote>
<p>Change them to:</p>
<blockquote><p>User your-mac-username<br />
Group staff</p></blockquote>
<p>- Staff is the non-admin user group in Mac.<br />
- If you are not sure about your mac username, open Finder > go to Macintosh HD > Users > Look for your folder&#8217;s name.</p>
<p>Now restart your XAMPP apache server and it should be working perfectly.</p>
]]></content:encoded>
			<wfw:commentRss>http://zenverse.net/wordpress-ftp-login-problem-xampp-mac-localhost/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

