<?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>Quinterox &#187; PHP</title>
	<atom:link href="http://www.quinterox.com/content/tag/php-learn/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.quinterox.com/content</link>
	<description>Cesar Quinteros</description>
	<lastBuildDate>Sun, 20 Jun 2010 04:51:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>.img Free Image Gallery</title>
		<link>http://www.quinterox.com/content/downloads/img-free-image-gallery/</link>
		<comments>http://www.quinterox.com/content/downloads/img-free-image-gallery/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 07:39:28 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Downloads]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[.img]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[free image gallery]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=658</guid>
		<description><![CDATA[Finally the PHP version of my free gallery Visual Gallery for ASP.NET: .img! Link me and enjoy!]]></description>
			<content:encoded><![CDATA[<p>Remember my free mini ASP.NET web application Visual Gallery? Well its long lost PHP brother is here! And again, it is FREE. All I ask for is a little credit. This time however I made it better with a little help from the JavaScript library <a title="jQuery" href="http://jquery.com/" target="_blank">jQuery</a> and its plugin <a title="jQuery lightbox" href="http://leandrovieira.com/projects/jquery/lightbox/" target="_blank">jQuery Lightbox</a> which really helped speed up the process! Thanks guys, you get a ton of credit from my part.</p>
<p>Currently there is no documentation on this app. However before using it there a couple of things you should know.</p>
<h3>You should know</h3>
<ol>
<li>You need &#8216;write&#8217; permission on the directory where you plan to house your galleries. This application generates resized images and thumbnails and stores them on your server. Without the permission the application will not work.</li>
<li>This application puts ALL the thumbnails of your gallery on the same page. So if you have a million pictures, it will show a million thumbnails. Some web users like myself might find this bothersome. I will try to change it in the future but keep that in mind for now. My recommendation: make different galleries for different things.</li>
<li>The application might not like and therefore might not link up thumbnails and full sized-images with special characters correctly. Again, will be fixed at a later time. For now try to avoid odd characters in your gallery images names.</li>
<li><strong>This application only supports (at the moment) JPEG images. Sorry GIF lovers, maybe on the next update.</strong></li>
<li>Don&#8217;t forget to add your own title on the &#8216;index.php&#8217; file and for search engine optimization I recommend changing the &#8216;author&#8217; and &#8216;description&#8217; meta tags on the html head to fit your needs.</li>
<li>Give lots of love to the jQuery folks and a little to myself. <a href="http://www.dreamhost.com/donate.cgi?id=11277" target="_self">Maybe in the form of a donation to help me pay my hosting</a>? Try the app first though, make sure it works for you.</li>
</ol>
<h3>Installation</h3>
<ol>
<li>Make sure you have &#8216;write&#8217; permission on the folder you wish to store your galleries. You might be able to use your FTP software to change the permission. I recommend setting the permission to CHMOD 0755.</li>
<li>Go into the file &#8216;index.php&#8217; and change the gallery title and meta tags (optional) to fit your needs.</li>
<li>Copy all the <i>.img</i> files to a subdirectory in your gallery&#8217;s directory.
<p>Example:</p>
<p>Main gallery: &#8220;/pictures/&#8221;</p>
<p>Where to put <i>.img</i> files: &#8220;/pictures/italy2009/&#8221; or &#8220;/pictures/mycars/&#8221;.</li>
<li>Delete the sample image&#8217;s and any subdirectories i&#8217;ve included in the &#8216;images&#8217; folder that came with this application.</li>
<li>Rename the htaccess.txt file to .htaccess</li>
<li>Upload your own image files via FTP to the &#8216;images&#8217; folder that came with this application.</li>
<li>Use your web browser to navigate to the location of the subdirectory where you placed the <i>.img</i> files. On the first run the application might take some time to load. This is because it is creating thumbnails and resizing your images (if it thinks theyre too big) in the background. After that is done, it will load much faster, as it has no more images to create.</li>
</ol>
<h3>Also</h3>
<p>If you plan to add/remove/rename images from the &#8216;image&#8217; directory, it is best to delete the &#8216;thumbs&#8217; and &#8216;resized&#8217; folder and rerun the application. This is because eventually you&#8217;ll be left with unused, leftover images in those directories which might confuse you later.</p>
<p>Demo: <a href="http://quinterox.com/shared/handled/dotimg_v1.12J/">http://quinterox.com/shared/handled/dotimg_v1.12J/</a></p>
<p>Download: <a class="downloadlink" href="http://www.quinterox.com/content/wp-content/plugins/download-monitor/download.php?id=img_v1.12.zip" title="Version1.12 downloaded 38 times" >.img (38)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/downloads/img-free-image-gallery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting to a MySQL database</title>
		<link>http://www.quinterox.com/content/code/connecting-to-a-mysql-database/</link>
		<comments>http://www.quinterox.com/content/code/connecting-to-a-mysql-database/#comments</comments>
		<pubDate>Fri, 02 Jan 2009 04:59:19 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[connecting]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=477</guid>
		<description><![CDATA[Simple steps to connect to and extract data from a MySQL database.]]></description>
			<content:encoded><![CDATA[<p>Below are the steps to connect to and extract data from a MySQL database.</p>
<h3>Connecting to the database</h3>
<p>Step 1. Create and configure some connection variables.</p>
<pre>
$mysql_server = "mysql.yourserver.com";
$mysql_user = "admin";
$mysql_pwd= "password";
$mysql_db= "mydatabase";
</pre>
<p><br class="clear" /><br />
Step 2. Create connection.</p>
<pre>
$mysql_connection =
mysql_connect($mysql_server, $mysql_user, $mysql_pwd);
</pre>
<p><br class="clear" /><br />
Step 3. Select your database.</p>
<pre>
mysql_select_db($mysql_db) or die("Unable to select a database.");
</pre>
<p><br class="clear" /><br />
Step 4. Create your SQL string.</p>
<pre>
$mysql_sql = "SELECT * FROM mytable";
</pre>
<p><br class="clear" /><br />
Step 5. Combine your connection string and your SQL to return data.</p>
<pre>
$mysql_result = mysql_query($mysql_sql, $mysql_connection);
</pre>
<p><br class="clear" /></p>
<h3>Printing the data</h3>
<p>Step 6. Loop through the results and write it to the page. This output&#8217;s format is not pretty since it is meant to be simple.</p>
<pre>
while($data_row = mysql_fetch_row($mysql_result)) {
    foreach($data_row as $data_field) {
        print $data_field;
    }
    print "&lt;br /&gt;";
}
</pre>
<p><br class="clear" /><br />
Step 7. Close the connection string.</p>
<pre>
mysql_close($mysql_connection);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/connecting-to-a-mysql-database/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ETag Removal</title>
		<link>http://www.quinterox.com/content/code/etag-removal/</link>
		<comments>http://www.quinterox.com/content/code/etag-removal/#comments</comments>
		<pubDate>Fri, 21 Nov 2008 05:24:29 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ETag]]></category>
		<category><![CDATA[Remove]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=429</guid>
		<description><![CDATA[Simple ETag removal.]]></description>
			<content:encoded><![CDATA[<p>The main purpose of ETags is for servers to validate whether there is a new version of the file they are requesting. The problem is that sites served on multiple servers are likely to have ETags that do not match. This problem exists for both IIS and Apache served sites. This mismatch is not important in a small site served by a single server. However it is suggested that ETags be removed on larger websites with multiple servers, this decreases header data and thus allows for a faster load. Leaving the mismatching ETag however is said to bog down busier sites. Below is a simple piece of code that shows you how to remove ETags, just add it to your .htaccess file.</p>
<pre>FileETag None</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/etag-removal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dynamically Getting File and Website Address</title>
		<link>http://www.quinterox.com/content/code/dynamically-getting-file-and-website-address/</link>
		<comments>http://www.quinterox.com/content/code/dynamically-getting-file-and-website-address/#comments</comments>
		<pubDate>Thu, 13 Nov 2008 06:49:07 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[dynamic file address]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=393</guid>
		<description><![CDATA[Getting the current web site's address or the current file location is simple in PHP. Here are a few examples.]]></description>
			<content:encoded><![CDATA[<p>Getting the current web site&#8217;s address is pretty simple and straight forward in PHP, no crazy functions nor regular expressions are needed. Below I demonstrate how to achieve this one line of code. Also I shall show you how to retrieve the page&#8217;s path from the root.</p>
<p>1. Get the current website address.</p>
<pre>$website = $_SERVER['HTTP_HOST'];</pre>
<p>Woah that was simple! Now the current folder path.</p>
<p>2. Get the current folder path.</p>
<pre>$filePath= $_SERVER['REQUEST_URI'];</pre>
<p>Did you catch that? It was so fast.</p>
<p>Put the first part and the second together (and of course add an &#8220;http://&#8221;) and you have the current file&#8217;s complete url!</p>
<pre>$fileWebAddress= "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/dynamically-getting-file-and-website-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; Where to place your code</title>
		<link>http://www.quinterox.com/content/code/php-where-to-place-your-code/</link>
		<comments>http://www.quinterox.com/content/code/php-where-to-place-your-code/#comments</comments>
		<pubDate>Thu, 30 Oct 2008 06:11:15 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[script tag]]></category>

		<guid isPermaLink="false">http://www.quinterox.com/content/?p=394</guid>
		<description><![CDATA[There are a few places where to place your PHP code on your dynamic web page. This all depends on your needs and preference. Of course there is a slight difference to whether you put it on a script tag, before any HTML, within your HTML, or at the bottom of the page. Here I will explain what I have found some of the differences to be.]]></description>
			<content:encoded><![CDATA[<p>There are a few places where to place your PHP code on your dynamic web page. This all depends on your needs and preference. Of course there is a slight difference to whether you put it on a script tag, before any HTML, within your HTML, or at the bottom of the page. Here I will explain what I have found some of the differences to be.</p>
<h3>Before HTML</h3>
<p>A few of the reasons you would want to place your code before the HTML are because you want to redirect the user to another page on your website, or getting data out of a database and placing it on your page as content.</p>
<pre><span style="color: #ff6600;"><span>&lt;?<span>php</span> $<span>pageTitle</span> = "Cesar's page"; ?&gt;</span></span>
<span>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.<span>dtd</span>"&gt;</span>
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
<span>&lt;meta http-equiv="Content-Type" content="text/html; <span>charset</span>=<span>utf</span>-8" /&gt;</span>
&lt;title&gt;<span style="color: #ff6600;"><strong><span>&lt;?<span>php</span> echo $<span>pageTitle</span>; ?&gt;</span></strong></span>&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt; ...</pre>
<p><br class="break" /></p>
<h3>In the script tag</h3>
<p>Yes! Just like Javascript you can place your PHP code within a script tag, but also like Javascript gets executed after your page loads. Though I have not seen many people using this method I think it really helps you keep your code clean and organized. It is similar to the .NET code placement.</p>
<pre><span>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.<span>dtd</span>"&gt;</span>
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
<span>&lt;meta http-equiv="Content-Type" content="text/html; <span>charset</span>=<span>utf</span>-8" /&gt;</span>
&lt;title&gt;My Web Page&lt;/title&gt;
<span style="color: #ff6600;"><strong><span>&lt;script language="<span>php</span>"&gt;</span>
$pageContent = "Cesar's page content.";
&lt;/script&gt;</strong>
</span>&lt;/head&gt;
&lt;body&gt;
<span>&lt;?<span>php</span> echo $<span>pageContent</span>; ?&gt;</span>
&lt;/body&gt;
&lt;/html&gt;</pre>
<p><br class="break" /></p>
<h3>Within HTML</h3>
<p>Mixing HTML and PHP is probably the most common way PHP applications are made. As useful and conventional as this type of coding can be, it can also become confusing. Below is an example of how that looks.</p>
<pre><span>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.<span>dtd</span>"&gt;</span>
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
<span>&lt;meta http-equiv="Content-Type" content="text/html; <span>charset</span>=<span>utf</span>-8" /&gt;</span>
&lt;title&gt;My Web Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<span style="color: #ff6600;"><strong><span>&lt;?<span>php</span></span>
<span>$<span>HeadDiv</span> = "&lt;div&gt;&lt;h1&gt;Welcome to my website!&lt;/h1&gt;&lt;/div&gt;";</span>
$BodyDiv = "&lt;div&gt;&lt;p&gt;Are you ready to hire me?! Click on my port...&lt;/p&gt;&lt;/div&gt;";
<span>$<span>FooterDiv</span> = "&lt;div&gt;copyright ...&lt;/div&gt;";</span>
?&gt;
<span>&lt;?<span>php</span></span>
<span>echo $<span>HeadDiv</span>;</span>
<span>echo $<span>BodyDiv</span>;</span>
<span>echo $<span>FooterDiv</span>;</span>
?&gt;</strong>
</span>&lt;/body&gt;
&lt;/html&gt;</pre>
<p><br class="break" /></p>
<h3>After HTML</h3>
<p>This might be an unorthodox way of code execution but nonetheless it is a possibility and depending on your application needs, it might be a useful one. Your code will execute after the HTML so anything that would be rendered above your HTML will render below it (afterwards) now. Here is how that looks. Please comment if you have an idea of how it would be useful.</p>
<pre><span>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.<span>dtd</span>"&gt;</span>
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
<span>&lt;meta http-equiv="Content-Type" content="text/html; <span>charset</span>=<span>utf</span>-8" /&gt;</span>
&lt;title&gt;My WebApp&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
<span>&lt;form action="/code/untitled.<span>php</span>" method="post"&gt;</span>
&lt;input type="text" name="txtMessage" /&gt;
&lt;input type="submit" value="submit" /&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
<strong><span style="color: #ff6600;"><span>&lt;?<span>php</span> echo $_POST['txtMessage'];?&gt;</span></span></strong></pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/php-where-to-place-your-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loops: break &amp; continue statements</title>
		<link>http://www.quinterox.com/content/code/loops-break-continue-statements/</link>
		<comments>http://www.quinterox.com/content/code/loops-break-continue-statements/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 18:05:45 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[break]]></category>
		<category><![CDATA[continue]]></category>
		<category><![CDATA[loops]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=19</guid>
		<description><![CDATA[Simple and easy to understand explanations of loop, break, and continue statements.]]></description>
			<content:encoded><![CDATA[<h3>Break</h3>
<p>Loops are very useful to help sift through information for what you need. However once you find your data you probably would like your loop to stop. For that you would have to use the BREAK statement.<br />
In this case the BREAK statement was used to not generate a division by zero warning. Watch as the code is stopped right before division by zero occurs.</p>
<pre>&lt;?php
$count = -10;
for (;$count &lt;= 10; $count++) {
     if ($count == 0) {
     break;
     } else {
             $result = 200/$count;
             echo "200 divided by $count is $result&lt;br /&gt;";
     }
}
?&gt;</pre>
<p><strong>Results: </strong><br />
200 divided by -10 is -20<br />
200 divided by -9 is -22.222222222222<br />
200 divided by -8 is -25<br />
200 divided by -7 is -28.571428571429<br />
200 divided by -6 is -33.333333333333<br />
200 divided by -5 is -40<br />
200 divided by -4 is  -50<br />
200 divided by -3 is -66.666666666667<br />
200 divided by -2 is -100<br />
200 divided by -1 is -200</p>
<h3>Continue</h3>
<p>The continue statement ends the execution of the current code lap but doesn&#8217;t stop the whole loop from continuing.</p>
<p>The following code, similar to the break, will stop the code from dividing by zero but continue afterwards.</p>
<pre>&lt;?php
$count = -10;
for (;$count &lt;= 10; $count++) {
     if ($count == 0) {
     continue;
     } else {
             $result = 200/$count;
             echo "200 divided by $count is $result&lt;br /&gt;";
     }
}
?&gt;</pre>
<p><strong>Results:</strong><br />
200 divided by -10 is -20<br />
200 divided by -9 is -22.222222222222<br />
200 divided by -8 is -25<br />
200 divided by -7 is -28.571428571429<br />
200 divided by -6 is -33.333333333333<br />
200 divided by -5 is -40<br />
200 divided by -4 is -50<br />
200 divided by -3 is -66.666666666667<br />
200 divided by -2 is -100<br />
200 divided by -1 is -200<br />
200 divided by 1 is 200<br />
200 divided by 2 is 100<br />
200 divided by 3 is 66.666666666667<br />
200 divided by 4 is 50<br />
200 divided by 5 is 40<br />
200 divided by 6 is 33.333333333333<br />
200 divided by 7 is 28.571428571429<br />
200 divided by 8 is 25<br />
200 divided by 9 is 22.222222222222<br />
200 divided by 10 is 20</p>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/loops-break-continue-statements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Loops</title>
		<link>http://www.quinterox.com/content/code/php-learn/loops/</link>
		<comments>http://www.quinterox.com/content/code/php-learn/loops/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 02:49:46 +0000</pubDate>
		<dc:creator>Cesar Quinteros</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[loops]]></category>

		<guid isPermaLink="false">http://quinterox.com/code/?p=16</guid>
		<description><![CDATA[Examples of While, Do While, and For loops.]]></description>
			<content:encoded><![CDATA[<h3>While</h3>
<pre>&lt;?php
$count = 1;
while ($count &lt;= 12) {
        echo $count . "&lt;br /&gt;";
        $count++;
}
?&gt;</pre>
<p><br class="break" /></p>
<h3>Do while</h3>
<p>Similar to a while loop with the exception that the code block is executed before the loop repeats. Note how it does not keep executing after the code realizes $number is not greater than 100 and less than 200.</p>
<pre>&lt;?php
$number = 1;
do {
    echo $number . "&lt;br /&gt;";
    $number ++;
} while (($number &gt; 100) &amp;&amp; ($number &lt; 200));
?&gt;</pre>
<p><br class="break" /></p>
<h3>For (each)</h3>
<p>Like the While statement but without having to declare variables outside the loop. The For statement includes the variable which you are incrementing in one line of code.</p>
<pre>&lt;?php
for ($count = 1; $count &lt;= 12; $count++) {
     echo $count . "&lt;br /&gt;"
}
?&gt;</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.quinterox.com/content/code/php-learn/loops/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
