<?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>Element Design &#187; PHP</title>
	<atom:link href="http://elementdesignllc.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://elementdesignllc.com</link>
	<description></description>
	<lastBuildDate>Tue, 31 Jan 2012 18:58:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>How to Fix Timthumb using a Virtual Directory (URL contains tildes (~))</title>
		<link>http://elementdesignllc.com/2012/01/how-to-fix-timthumb-using-a-virtual-directory-url-contains-tildes/</link>
		<comments>http://elementdesignllc.com/2012/01/how-to-fix-timthumb-using-a-virtual-directory-url-contains-tildes/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 14:00:30 +0000</pubDate>
		<dc:creator>chad</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://elementdesignllc.com/?p=991</guid>
		<description><![CDATA[The timthumb tilde issue has been discussed for almost a year now on the official timthumb site, and the developers have yet to do anything to provide a fix for users in development environments. The issue is that when developers are developing sites using a URL structure such as: http://127.0.0.1/~mysite/images/dog.jpg, timthumb does not correctly parse [...]]]></description>
			<content:encoded><![CDATA[<p>The timthumb tilde issue has been discussed for almost a year now on the official timthumb site, and the developers have yet to do anything to provide a fix for users in development environments.</p>
<p>The issue is that when developers are developing sites using a URL structure such as: http://127.0.0.1/~mysite/images/dog.jpg, timthumb does not correctly parse the folder structure and returns a broken image. In this case, a proper path might be: /home/mysite/public_html/images/dog.jpg, however timthumb creates the broken path: /home/mysite/public_html/~mysite/images/dog.jpg.</p>
<p>For the record, I believe timthumb is a horrible idea and should be avoided at all costs (security and performance issues). However there are many instances where you might purchase a template to find it is completely integrated with timthumb, and the amount of time it could take to remove timthumb from the template is not worth it.</p>
<h3>How to fix</h3>
<p>Make sure you are using the <a href="http://timthumb.googlecode.com/svn/trunk/timthumb.php" target="_blank">latest version of timthumb</a>. At the moment of this writing, the version is 2.8.5</p>
<p>At line 209 you will find the code:</p>
<pre class="brush: php; title: ; notranslate">
$this-&gt;src = $this-&gt;param('src');
</pre>
<p><em><strong>Replace</strong></em> that with:</p>
<pre class="brush: php; title: ; notranslate">
//check if tilde is found in src
if(strstr($this-&gt;param('src'),'~'))
{
   $url_parts = explode('/',$this-&gt;param('src'));

   foreach($url_parts as $url_part)
   {
      //do not include any part with a ~ when building new url
      if(!strstr($url_part,'~'))
      {
         $new_dev_url .= $url_part.'/';
      }
   }

   //remove trailing slash
   $new_dev_url = substr($new_dev_url,0,-1);

   $this-&gt;src = $new_dev_url;
}
else
{
   $this-&gt;src = $this-&gt;param('src');
}
</pre>
<p>This isn&#8217;t the most elegant solution, however the only time you should be using it is while you are developing and debugging the site (tildes should never be in the URL of a live website). Once you go live, it will automatically skip over that extra processing and work just as timthumb is intended.</p>
<h3>Additional fix for $_SERVER['DOCUMENT_ROOT']</h3>
<p>There might be a chance that timthumb is still not working, and that could be because $_SERVER['DOCUMENT_ROOT'] is not being properly defined. To get around this, we need to manually define $_SERVER['DOCUMENT_ROOT'] at the beginning of the document:</p>
<p><em><strong>Above</strong></em> this line (line 23):</p>
<pre class="brush: php; title: ; notranslate">
define ('VERSION', '2.8.5');
</pre>
<p>Insert the root path of your website, something like this:</p>
<pre class="brush: php; title: ; notranslate">
$_SERVER['DOCUMENT_ROOT'] = '/home/mysite/public_html/';
</pre>
<p>I hope that helps, and if it is still not working for you, I highly recommend visiting the <a href="http://code.google.com/p/timthumb/" target="_blank">official timthumb website</a> and talk with the developers.</p>
]]></content:encoded>
			<wfw:commentRss>http://elementdesignllc.com/2012/01/how-to-fix-timthumb-using-a-virtual-directory-url-contains-tildes/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generate Random 10 Digit Number in PHP</title>
		<link>http://elementdesignllc.com/2011/06/generate-random-10-digit-number-in-php/</link>
		<comments>http://elementdesignllc.com/2011/06/generate-random-10-digit-number-in-php/#comments</comments>
		<pubDate>Thu, 23 Jun 2011 13:43:13 +0000</pubDate>
		<dc:creator>chad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Quick Tips]]></category>

		<guid isPermaLink="false">http://elementdesignllc.com/?p=923</guid>
		<description><![CDATA[The application I&#8217;m developing requires a random 10 digit number as a bar code on season pass. A simple way to create a unique number is to use the following code: Here&#8217;s whats happening with the code: The outer portion &#8220;substr&#8221; is used to chop down the random number we create to 10 characters. You [...]]]></description>
			<content:encoded><![CDATA[<p>The application I&#8217;m developing requires a random 10 digit number as a bar code on season pass. A simple way to create a unique number is to use the following code:</p>
<pre class="brush: php; title: ; notranslate">
$random = substr(number_format(time() * rand(),0,'',''),0,10);
</pre>
<p>Here&#8217;s whats happening with the code:</p>
<p>The outer portion &#8220;<a href="http://us2.php.net/substr" target="_blank">substr</a>&#8221; is used to chop down the random number we create to 10 characters. You will notice the number 10 at the end of the snippet, which can be changed to any number you want.</p>
<p>The &#8220;<a href="http://us2.php.net/number_format" target="_blank">number_format</a>&#8221; function helps get rid of the scientific notation that will arise from generating the random number. In the middle, &#8220;<a href="http://us2.php.net/time" target="_blank">time()</a>&#8221; and &#8220;<a href="http://us2.php.net/rand" target="_blank">rand()</a>&#8221; are multiplied. Time() is the number of seconds from January 1 1970, and rand() is a uniquely generated number through PHP.</p>
<p>Always remember that generating unique numbers is not fool proof.  If your application requires each number to be unique, perform a collision check in the database before saving.</p>
]]></content:encoded>
			<wfw:commentRss>http://elementdesignllc.com/2011/06/generate-random-10-digit-number-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple PHP Random Image Script</title>
		<link>http://elementdesignllc.com/2010/03/php-random-image-script/</link>
		<comments>http://elementdesignllc.com/2010/03/php-random-image-script/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 13:00:16 +0000</pubDate>
		<dc:creator>chad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[rand()]]></category>
		<category><![CDATA[random image]]></category>

		<guid isPermaLink="false">http://elementdesignllc.com/?p=518</guid>
		<description><![CDATA[There are times when working with smaller sites you need a simple method of displaying random images. This can be done in one line of text directly in your HTML and a collection of images. Prepare the Images The first step is to gather together the images you wish to have randomly rotated. Change all [...]]]></description>
			<content:encoded><![CDATA[<p>There are times when working with smaller sites you need a simple method of displaying random images. This can be done in one line of text directly in your HTML and a collection of images.</p>
<h3>Prepare the Images</h3>
<p>The first step is to gather together the images you wish to have randomly rotated. Change all of their file names to a numerical order, starting with the number 1.</p>
<ul>
<li>1.jpg</li>
<li>2.jpg</li>
<li>3.jpg</li>
<li>4.jpg</li>
</ul>
<p>Be sure each image has the same extension (either all jpg, png, or gif), and that there are no gaps in the numbers. Also, place these images in their own folder to keep everything organized.</p>
<h3>Write the Code</h3>
<p>Now in the HTML of your page, insert the following code where you want an image to display:</p>
<pre class="brush: php; title: ; notranslate">
&lt;img src=&quot;/path/to/&lt;?php echo rand(1,n);?&gt;.jpg&quot; alt=&quot;Random Image&quot; /&gt;
</pre>
<p>The &#8220;rand&#8221; operator will display a randomly generated number between 1 and &#8216;n&#8217;. Change &#8216;n&#8217; to the total amount of pictures you have arranged numerically (or the highest numbered picture you have). In the example above I only have 4 pictures, therefor I would change it to: rand(1,4);</p>
<p>To finish it off, change &#8216;/path/to/&#8217; to the path your stored the images in.</p>
]]></content:encoded>
			<wfw:commentRss>http://elementdesignllc.com/2010/03/php-random-image-script/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>PHP 5.3 and MySQLi Prepared Statements</title>
		<link>http://elementdesignllc.com/2009/11/php-5-3-and-mysqli-prepared-statements/</link>
		<comments>http://elementdesignllc.com/2009/11/php-5-3-and-mysqli-prepared-statements/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 16:06:02 +0000</pubDate>
		<dc:creator>chad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysqli]]></category>
		<category><![CDATA[prepared statements]]></category>

		<guid isPermaLink="false">http://elementdesignllc.com/?p=409</guid>
		<description><![CDATA[There seems to be an issue with PHP 5.3 and MySQLi Prepared Statements. The procedural code I wrote works fine in 5.2.x, but once I upgraded to 5.3, the results were bizzare. It would pull about 20-50 characters from the field, duplicate the last several characters over and over again (in and around the div [...]]]></description>
			<content:encoded><![CDATA[<p>There seems to be an issue with PHP 5.3 and MySQLi Prepared Statements. The procedural code I wrote works fine in 5.2.x, but once I upgraded to 5.3, the results were bizzare. It would pull about 20-50 characters from the field, duplicate the last several characters over and over again (in and around the div container I had set for it), and even change some of the HTML code that was supposed to be outputted onto the page.</p>
<p>So if you are using prepared statements, I recommend staying away from 5.3 until they get everything ironed out.</p>
]]></content:encoded>
			<wfw:commentRss>http://elementdesignllc.com/2009/11/php-5-3-and-mysqli-prepared-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP APC for Windows Download</title>
		<link>http://elementdesignllc.com/2009/08/php-apc-for-windows-download/</link>
		<comments>http://elementdesignllc.com/2009/08/php-apc-for-windows-download/#comments</comments>
		<pubDate>Wed, 19 Aug 2009 15:46:55 +0000</pubDate>
		<dc:creator>chad</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[apc]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[windows]]></category>

		<guid isPermaLink="false">http://elementdesignllc.com/?p=259</guid>
		<description><![CDATA[PECL 4 Win has been down for quite a while making the search for some PHP extensions unnecessarily difficult. I&#8217;m offering this permanent APC download for not only my records, but to help others searching for it. As of August 19th, 2009, 3.1.3 is the latest beta version, and 3.0.19 is the latest stable. Download [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://pecl4win.php.net/" target="_blank">PECL 4 Win</a> has been down for quite a while making the search for some PHP extensions unnecessarily difficult. I&#8217;m offering this permanent APC download for not only my records, but to help others searching for it. As of August 19th, 2009, 3.1.3 is the latest beta version, and 3.0.19 is the latest stable.</p>
<p><a href="http://elementdesignllc.com/wp-content/uploads/php_apc_3_0_19.dll">Download php_apc (Windows 3.0.19 Stable)</a></p>
<p><a href="http://elementdesignllc.com/wp-content/uploads/php_apc_3_1_3.dll">Download php_apc (Windows 3.1.3 Beta)</a></p>
<p>For more information on APC, please visit the <a href="http://pecl.php.net/package/APC" target="_blank">PECL page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://elementdesignllc.com/2009/08/php-apc-for-windows-download/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
	</channel>
</rss>

