<?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>Lost Whisper &#187; PHP</title>
	<atom:link href="http://lost-whisper.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://lost-whisper.com</link>
	<description>Yet another whisper lost.</description>
	<lastBuildDate>Thu, 28 Apr 2011 18:33:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>MongoDB and PHP on Webfaction</title>
		<link>http://lost-whisper.com/2010/06/16/mongodb-and-php-on-webfaction/</link>
		<comments>http://lost-whisper.com/2010/06/16/mongodb-and-php-on-webfaction/#comments</comments>
		<pubDate>Wed, 16 Jun 2010 23:20:45 +0000</pubDate>
		<dc:creator>TwiRp</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[webfaction]]></category>

		<guid isPermaLink="false">http://lost-whisper.com/?p=447</guid>
		<description><![CDATA[So, this summer I decided I was going to try to learn some new things and update myself to some of the newer stuff out there. So PHP 5 added a whole slew of new features to PHP, but I&#8217;ve been stuck in PHP 4, so I figured I&#8217;d learn some of that. Â I&#8217;ve also [...]]]></description>
			<content:encoded><![CDATA[<p>So, this summer I decided I was going to try to learn some new things and update myself to some of the newer stuff out there.</p>
<p>So PHP 5 added a whole slew of new features to PHP, but I&#8217;ve been stuck in PHP 4, so I figured I&#8217;d learn some of that. Â I&#8217;ve also been stuck to relational databases (and that&#8217;s usually what they teach at school), but I&#8217;ve started to see some of the sites I know and love switching to non-relational databases. Â So that was also something I wanted to learn how to work with.</p>
<p>I went online to search, and the three major contenders seem to be <a href="http://cassandra.apache.org/">Cassandra</a>, <a href="http://couchdb.apache.org/">CouchDB</a>, and <a href="http://www.mongodb.org/">MongoDB</a>. Â I decided to go with MongoDB since it seemed like the easiest to use and setup, and I liked the idea of document-oriented storage. Â CouchDB can be ran on <a href="http://www.webfaction.com?affiliate=emokid">webFaction</a> as well, but I&#8217;m not too sure about Cassandra (I&#8217;m guessing you can with effort).</p>
<p>So here&#8217;s my guide on getting it setup and ready to run.</p>
<p><span id="more-447"></span></p>
<p>So installing <a href="http://www.mongodb.org">MongoDB</a> on <a href="http://www.webfaction.com?affiliate=emokid">Webfaction</a>:</p>
<ol>
<li>Create a new custom application listening on port called mongodb</li>
<li>Create it and take note of the port</li>
<li>Login to your account via SSH</li>
<li>Switch to the directory of the mongodb app you just created<br />
<em>cd ~/webapps/mongodb</em></li>
<li>Download the latest version of the 32-bit version of MongoDB (1.4.3 as of writing)<br />
<em>wget http://downloads.mongodb.org/linux/mongodb-linux-i686-1.4.3.tgz</em></li>
<li>Extract the files from the archive<br />
<em>tar -xf mongodb-linux-i686-1.4.3.tgz</em></li>
<li>Create a data directory for your MongoDB installation<br />
<em>mkdir data</em></li>
<li><em> </em>Start up MongoDB<br />
<em>/home/[user]/webapps/mongodb/mongodb-linux-i686-1.4.3/bin/mongod &#8210;&#8210;dbpath /home/[user]/webapps/mongodb/data/ &#8210;&#8210;port [port]</em></li>
</ol>
<p>Doing that will launch MongoDB in the terminal. Â To have MongoDB run as a background process and restart should it quit can be done with a few scripts. Â My way isn&#8217;t probably the most elegant way to do it. Â If mongoDB doesn&#8217;t exit cleanly, then you have to delete the lock, run repair, and restart the daemon, so there are 3 parts to my way and a dummy file, but you can probably easily merge it all into one file (I&#8217;m just too interested in playing with PHP and MongoDB to do so yet).</p>
<p>This is <strong>mongo.sh</strong>, it checks if the mongo daemon (mongod) is running, and it calls the appropriate action.</p>
<p style="padding-left: 30px;">
<div id="_mcePaste" style="padding-left: 30px;"><em>#!/bin/bash</em></div>
<div id="_mcePaste" style="padding-left: 30px;"><em># check if mongod is running</em></div>
<div id="_mcePaste" style="padding-left: 30px;"><em>ps -u [user] | grep -v grep | grep mongod</em></div>
<div id="_mcePaste" style="padding-left: 30px;"><em># if not found &#8211; equals to 1, start it</em></div>
<div id="_mcePaste" style="padding-left: 30px;"><em>if [ $? -eq 1 ]</em></div>
<div id="_mcePaste" style="padding-left: 30px;"><em>then</em></div>
<div id="_mcePaste" style="padding-left: 30px;"><em>/home/[user]/webapps/mongodb/startmongo.sh</em></div>
<div id="_mcePaste" style="padding-left: 30px;"><em>else</em></div>
<div id="_mcePaste" style="padding-left: 30px;"><em>/home/[user]/webapps/mongodb/runningmongo.sh</em></div>
<div id="_mcePaste" style="padding-left: 30px;"><em>fi</em></div>
<p>This is <strong>startmongo.sh</strong>, there&#8217;s a dummy file called &#8220;isnt_running.txt&#8221; Â If it exists when startmongo.sh is ran, that means that mongod didn&#8217;t exit cleanly. Â If it didn&#8217;t exit cleanly, we have to delete mongod.lock and run repair on the database. Â Otherwise, we just try to start up mongod.</p>
<p style="padding-left: 30px;"><em>#!/usr/bin/env php<br />
&lt;?php<br />
// Check if MongoDB did not exit cleanly<br />
if(file_exists(&#8220;/home/[user]/webapps/mongodb/isnt_running.txt&#8221;)){<br />
unlink(&#8220;/home/[user]/webapps/mongodb/data/mongod.lock&#8221;);<br />
exec(&#8220;/home/[user]/webapps/mongodb/mongodb-1.4.3/bin/mongod &#8210;&#8210;dbpathÂ /home/[user]/webapps/mongodb/data &#8210;&#8210;port [port] &#8210;&#8210;auth &#8210;&#8210;repair&#8221;);<br />
exec(&#8220;nohup /home/[user]/webapps/mongodb/mongodb-1.4.3/bin/mongod &#8210;&#8210;dbpath /home/[user]/webapps/mongodb/data &#8210;&#8210;port [port] &#8210;&#8210;auth&#8221;);<br />
}else{<br />
exec(&#8220;nohup /home/[user]/webapps/mongodb/mongodb-1.4.3/bin/mongod &#8210;&#8210;dbpath /home/emokid/webapps/mongodb/data &#8210;&#8210;port [port] &#8210;&#8210;auth&#8221;);<br />
$fp = fopen(&#8220;/home/[user]/webapps/mongodb/isnt_running.txt&#8221;, &#8220;w+&#8221;);<br />
fwrite($fp, &#8220;Starting up&#8221;);<br />
fclose($fp);<br />
}<br />
?&gt;</em></p>
<p>This is <strong>runningmongo.sh</strong>, it just deletes our dummy file letting us know that mongod is running.</p>
<p style="padding-left: 30px;"><em>#!/usr/bin/env php<br />
&lt;?php<br />
// Check if MongoDB did not exit cleanly<br />
if(file_exists(&#8220;/home/emokid/webapps/mongodb/isnt_running.txt&#8221;)){<br />
unlink(&#8220;/home/emokid/webapps/mongodb/isnt_running.txt&#8221;);<br />
}<br />
?&gt;</em></p>
<p>I just add mongo.sh to the crontab. Â Mine runs every 20 minutes, but you can make it run sooner because if it does run every 20 minutes, that mean that the database could be down for 40 minutes. Â Make sure to change [user] and [port] to your username and the port number you were given.</p>
<p><strong>crontab</strong></p>
<p style="padding-left: 30px;"><em>*/20 * * * * /home/[user]/webapps/mongodb/mongo.sh &gt; /dev/null 2&gt;&amp;1</em></p>
<h2>The PHP Stack</h2>
<p>In order to run PHP with the mongo drivers, you need your own installation of Apache and PHP. Â WebFaction makes this somewhat easy to do.</p>
<ol>
<li>Create a new custom application listening on port and call it phpstack</li>
<li>Take note of the port.</li>
<li>SSH onto the server and go to the phpstack webapp directory<br />
<em>cd ~/webapps/phpstack</em></li>
<li>Download the PHPStack setup script (this is the one for PHP 5.3.1).<br />
<em>wgetÂ http://wiki.webfaction.com/attachment/wiki/MiscellaneousFiles/build_php_worker_531.sh?format=raw</em></li>
<li><em> </em> Rename the script to build_php_worker_531.sh<br />
<em>mv build_php_worker_531.sh\?format\=raw build_php_worker_531.sh</em></li>
<li><em> </em>Make sure the script is executable.<br />
<em>chmod +x build_php_worker_531.sh</em></li>
<li><em></em>Run the install script and specify the path to the phpstack, and the port number<br />
<em>./build_php_worker_531.sh /home/[user]/webapps/phpstack [port]</em></li>
<li>We have to install <a href="http://pear.php.net/">Pear</a> twice in order to get <a href="http://pecl.php.net/">PECL</a>.
<ol>
<li>Download the go-pear.php installer script<br />
<em>wgetÂ http://pear.php.net/go-pear </em></li>
<li>Rename it to go-pear.php<br />
<em>mv go-pear go-pear.php</em></li>
<li><em></em>Run it with the php_fcgi version of php<br />
<em>/home/[user]/webapps/phpstack/php_fcgi/bin/php go-pear.php</em></li>
<li><em></em>When it asks you about the paths, set $prefix to:<br />
<em>/home/[user]/webapps/phpstack/php_fcgi</em></li>
<li>Then run the installer. Â Repeat the process for <em>php_rawcgi</em></li>
<li><em></em>For each installation (php_fcgi and php_rawcgi) run<br />
<em>/home/[user]/webapps/phpstack/php_fcgi/bin/pecl install mongo</em></li>
<li>Then in each php.ini (php_fcgi/lib/php.ini and php_rawcgi/lib/php.ini) add<br />
<em>extension=&#8221;mongo.so&#8221;</em></li>
</ol>
</li>
</ol>
<p>To keep things easy, you can place all of your website stuff inside of the phpstack/htdocs, or you can edit the httpd.conf to point towards one of your other webapps.</p>
<p>Now you might want to <a href="http://www.mongodb.org/display/DOCS/Security+and+Authentication">secure your MongoDB a bit</a>, and read up on <a href="http://php.net/manual/en/book.mongo.php">how to use it with PHP</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://lost-whisper.com/2010/06/16/mongodb-and-php-on-webfaction/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Brain Storming</title>
		<link>http://lost-whisper.com/2009/01/22/brain-storming/</link>
		<comments>http://lost-whisper.com/2009/01/22/brain-storming/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 03:37:04 +0000</pubDate>
		<dc:creator>TwiRp</dc:creator>
				<category><![CDATA[Internet]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://lost-whisper.com/?p=260</guid>
		<description><![CDATA[So, one of the assignments at school is to create a mash-up of web apps. I was thinking about what I want to do.Â  I really want to do a lifestream type mash-up.Â  Something different from the ones currently out there.Â  I won&#8217;t say too much about it, but it&#8217;ll be pretty cool. I&#8217;m currently [...]]]></description>
			<content:encoded><![CDATA[<p>So, one of the assignments at school is to create a mash-up of web apps.<br />
I was thinking about what I want to do.Â  I really want to do a lifestream type mash-up.Â  Something different from the ones currently out there.Â  I won&#8217;t say too much about it, but it&#8217;ll be pretty cool.<br />
I&#8217;m currently drafting out some plans for it.Â  I have it all figured out in my head, but it&#8217;s supposed to be a group project, so hopefully the people assigned to my group like the idea as well and understand and contribute their own ideas to it.</p>
<p>What&#8217;ll be different from the other &#8220;lifestream&#8221; type apps already out there?Â  Well, this one will be more central than the others.Â  It&#8217;ll also attempt to aid the user better (not taking control over the user&#8217;s life or anything, but offer something new and different).Â  It&#8217;ll also be plug-in based and some other things&#8230;Â  So yeah, it&#8217;s currently in the planning phase, but I hope to get something done before summer (whether or not it&#8217;s a project done for school).</p>
]]></content:encoded>
			<wfw:commentRss>http://lost-whisper.com/2009/01/22/brain-storming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Surpass is weird&#8230;</title>
		<link>http://lost-whisper.com/2006/12/14/surpass-is-weird/</link>
		<comments>http://lost-whisper.com/2006/12/14/surpass-is-weird/#comments</comments>
		<pubDate>Thu, 14 Dec 2006 22:05:56 +0000</pubDate>
		<dc:creator>TwiRp</dc:creator>
				<category><![CDATA[EQOTD]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://lost-whisper.info/2006/12/14/surpass-is-weird/</guid>
		<description><![CDATA[Okay, so Surpass is posting everything that goes wrong with the servers I think it&#8217;s kindof neat, except you wish that you&#8217;d be able to do something about it. Like if they posted the site that was causing the problems and an the contact e-mail. Then the users on the server could send some harassing [...]]]></description>
			<content:encoded><![CDATA[<p>Okay, so Surpass is <a href="http://surmunity.com/showthread.php?p=228608">posting everything that goes wrong with the servers</a><br />
I think it&#8217;s kindof neat, except you wish that you&#8217;d be able to do something about it.<br />
Like if they posted the site that was causing the problems and an the contact e-mail.<br />
Then the users on the server could send some harassing e-mails straightening the naughty person out.<br />
<a href="http://kaylafleming.com/site/transparency_really_travels/">Kayla</a> got loads of feedback on her new step of informing.  But she doesn&#8217;t know if the action is good or bad.<br />
I think it&#8217;s good.  It will show you that there are problems and the host knows what they are and you get to know if they are fixing it or not.  The only downside is you know the host does have problems.  But all hosts have problems, I think the most famous being DreamHost with the whole month of screwed-upness.  Dream host posts all of their problems at their <a href="http://dreamhoststatus.com/">status blog</a> the moment it happens, but it&#8217;s just technical stuff, and sometimes they are vague</p>
<blockquote><p>&#8220;We€™re not 100% sure what is causing these network problems, or what is being affected&#8221;</p></blockquote>
<p>So I think Surpass&#8217; thing is better.  But Surpass doesn&#8217;t seem to update on every network issue, not like that&#8217;s a problem because there is very little downtime unless it is a server problem (which is covered in the weekly report).  Plus, if there is a problem, it is usually posted in the forum informing people what happened.  The only issue I have with this is if it is a big error, you don&#8217;t here about it till it&#8217;s over.  This is somewhat why I like the DreamHostStatus because it&#8217;s hosted somewhere else.</p>
<p>I wonder if the reports help to increase hosts&#8217; sales or if they turn people away.  Or do people not know of their existence.  The world may never know.</p>
<p>But what we do know is today&#8217;s emo quote of the day:</p>
<blockquote><p>&#8220;My mom told me to get a hair cut.  I told her I know of 2 other <em>things</em> I <em>could cut</em>.&#8221;</p></blockquote>
<p>If you aren&#8217;t really getting what it means and need an explanation.  You have to wrists, and the term cut can be replaced with slit, but yeah&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://lost-whisper.com/2006/12/14/surpass-is-weird/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Optimizing Stuff&#8230;</title>
		<link>http://lost-whisper.com/2006/06/29/optimizing-stuff/</link>
		<comments>http://lost-whisper.com/2006/06/29/optimizing-stuff/#comments</comments>
		<pubDate>Thu, 29 Jun 2006 21:44:57 +0000</pubDate>
		<dc:creator>TwiRp</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://lost-whisper.info/2006/06/29/optimizing-stuff/</guid>
		<description><![CDATA[So&#8230; I&#8217;m working on trying to optimize T.N and some other scripts&#8230; So I&#8217;m trying to find out what works faster in PHP I read somewhere that mysql_result is faster than mysql_fetch_array but then I read that something was faster than mysql_result and yeah&#8230; So I&#8217;m also working on other parts as well, like the [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://lost-whisper.info/twirp.gif" />So&#8230;<br />
I&#8217;m working on trying to optimize T.N and some other scripts&#8230;<br />
So I&#8217;m trying to find out what works faster in PHP<br />
I read somewhere that mysql_result is faster than mysql_fetch_array<br />
but then I read that something was faster than mysql_result<br />
and yeah&#8230;</p>
<p>So I&#8217;m also working on other parts as well, like the private messaging&#8230;<br />
Yeah&#8230;<br />
I got to get back to work</p>
<p>Oh yeah,<br />
I also made it so if you have a gravatar, it will work throughout twirp.net and lost-whisper<br />
So instead of having to put in the URL for your avatar, if you already have a gravatar, there&#8217;s no need to worry about editing that part of your profile&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://lost-whisper.com/2006/06/29/optimizing-stuff/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Site Map</title>
		<link>http://lost-whisper.com/2006/06/27/site-map/</link>
		<comments>http://lost-whisper.com/2006/06/27/site-map/#comments</comments>
		<pubDate>Tue, 27 Jun 2006 22:19:21 +0000</pubDate>
		<dc:creator>TwiRp</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://lost-whisper.info/2006/06/27/site-map/</guid>
		<description><![CDATA[I added a site map just in case some visitor can&#8217;t use the menu at the top. You can access it by clicking on destination, or the warning at the bottom of the screen (if you&#8217;re using internet explorer). I also added a page for counters with some skins for the counter. There are 2 [...]]]></description>
			<content:encoded><![CDATA[<p><img align="left" src="http://lost-whisper.info/twirp.gif" />I added a <a href="http://lost-whisper.info/whisper/read/site_map">site map</a> just in case some visitor can&#8217;t use the menu at the top.<br />
You can access it by clicking on destination, or the warning at the bottom of the screen (if you&#8217;re using internet explorer).<br />
I also added a page for <a title="Counters" href="http://lost-whisper.info/whisper/read/counters">counters</a> with some skins for the counter.  There are 2 versions, a MySQL one, or a Text-File based one.<br />
I hope you like them.  Feel free to make the skins and submit them, there&#8217;s an e-mail on the download page you can send it to.</p>
<p>Anyways, there are 2 88*15 skins blue and orange, and blue and light blue.<br />
<img align="left" src="http://twirp.paruparo.org/counters/mysql/default.php" /><img src="http://twirp.paruparo.org/counters/mysql/blue_orange.php" /><br />
And 2 anime skins, one from FMA, and another from DN Angel.<br />
<img align="left" src="http://twirp.paruparo.org/counters/text/ed_counter.php" /><img align="left" src="http://twirp.paruparo.org/counters/text/daisuke_count.php" /></p>
<p><br clear="all" /></p>
]]></content:encoded>
			<wfw:commentRss>http://lost-whisper.com/2006/06/27/site-map/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Graphical Counter</title>
		<link>http://lost-whisper.com/2006/06/26/graphical-counter/</link>
		<comments>http://lost-whisper.com/2006/06/26/graphical-counter/#comments</comments>
		<pubDate>Mon, 26 Jun 2006 19:37:40 +0000</pubDate>
		<dc:creator>TwiRp</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://lost-whisper.info/2006/06/26/graphical-counter/</guid>
		<description><![CDATA[Want to make your own Graphical Counter like OKCounter?  Look at this tutorial, and will show you how to make your own graphical counter showing the number of unique hits today, and the total number of hits.]]></description>
			<content:encoded><![CDATA[<p><strong>What's Needed</strong></p>
<p>All we need is PHP and MySQL.<br />
<strong>Files We Will Make</strong></p>
<ul>
<li>count.php</li>
<li>image.php</li>
</ul>
<p>We could do it with one file, but I think it's easier to understand with 2 different files.  Plus, if you want to have different images, the count.php will log the stuff, and image.php will display the information.</p>
<p><strong>The SQL Query</strong></p>
<p>Creating the table.  We are going to try to keep it as simple as posible.</p>
<div class="igBar"><span id="lsql-1"><a href="#" onclick="javascript:showCodeTxt('sql-1'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-1">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> counter<span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">logging VARCHAR<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">5</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">number INT<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">5</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">ipaddr TEXT <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">daynum INT<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #cc66cc;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span><span style="color:#006600; font-weight:bold;">&#40;</span>logging<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p><span class="syntax_punct syntax_punct_queryend"><br />
</span></p>
<p>This creates the table we will use.  logging will store if it's storing information for today or total hits, and the ipaddr will store the IP of the visitors, number is the number of hits, and daynum is the number of the day.<br />
Now we need to insert some more information in the database.</p>
<div class="igBar"><span id="lsql-2"><a href="#" onclick="javascript:showCodeTxt('sql-2'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-2">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> counter <span style="color:#006600; font-weight:bold;">&#40;</span>logging,number<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'today'</span>,<span style="color: #ff0000;">'0'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lsql-3"><a href="#" onclick="javascript:showCodeTxt('sql-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">SQL:</span>
<div id="sql-3">
<div class="sql">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> counter <span style="color:#006600; font-weight:bold;">&#40;</span>logging,number<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color:#006600; font-weight:bold;">&#40;</span><span style="color: #ff0000;">'total'</span>,<span style="color: #ff0000;">'0'</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p>
This just creates the 2 storage location in the table we will use.</p>
<p><strong>Count.php</strong></p>
<p>Now we need the file that will store the information.  Hopefully you understand the internal documentation.</p>
<div class="igBar"><span id="lphp-4"><a href="#" onclick="javascript:showCodeTxt('php-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-4">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Database Information, Host, User, Password, and Database</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$DBHost</span> = <span style="color:#FF0000;">'localhost'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$DBUser</span> = <span style="color:#FF0000;">'user'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$DBPass</span> = <span style="color:#FF0000;">'pass'</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$DB</span> = <span style="color:#FF0000;">'database'</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Now to connect</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/mysql_connect"><span style="color:#000066;">mysql_connect</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$DBHost</span>, <span style="color:#0000FF;">$DBUser</span>, <span style="color:#0000FF;">$DBPass</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/mysql_select_db"><span style="color:#000066;">mysql_select_db</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$DB</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Select today's information</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$q</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"SELECT * FROM counter WHERE logging='today'"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$i</span> = <a href="http://www.php.net/mysql_fetch_array"><span style="color:#000066;">mysql_fetch_array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$q</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Get the total inforamtion</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$tq</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"SELECT * FROM coutner WHERE logging='total'"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$ti</span> = <a href="http://www.php.net/mysql_fetch_array"><span style="color:#000066;">mysql_fetch_array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$tq</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$total</span> = <span style="color:#0000FF;">$ti</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'number'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Check to see if it's storing todays information</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$date</span> = <a href="http://www.php.net/date"><span style="color:#000066;">date</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"d"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$i</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'daynum'</span><span style="color:#006600; font-weight:bold;">&#93;</span>==<span style="color:#0000FF;">$date</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Since it is, we get the current information</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span> = <span style="color:#0000FF;">$i</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'number'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$ips</span> = <a href="http://www.php.net/explode"><span style="color:#000066;">explode</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"|"</span>,<span style="color:#0000FF;">$i</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'ipaddr'</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Now to see if we need to increment the counter.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">if</span><span style="color:#006600; font-weight:bold;">&#40;</span>!<a href="http://www.php.net/in_array"><span style="color:#000066;">in_array</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$_SERVER</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'REMOTE_ADDR'</span><span style="color:#006600; font-weight:bold;">&#93;</span>,<span style="color:#0000FF;">$ips</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span>++;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$total</span>++;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Add the IP to the IP List</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$nip</span> = <span style="color:#0000FF;">$i</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'ipaddr'</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#FF0000;">'|'</span>.<span style="color:#0000FF;">$_SERVER</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'REMOTE_ADDR'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Update the Table</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$up</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"UPDATE counter SET number='"</span>.<span style="color:#0000FF;">$today</span>.<span style="color:#FF0000;">"', ipaddr='"</span>.<span style="color:#0000FF;">$nip</span>.<span style="color:#FF0000;">"' WHERE logging='today'"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$up2</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"UPDATE counter SET number='"</span>.<span style="color:#0000FF;">$total</span>.<span style="color:#FF0000;">"' WHERE logging='total'"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#616100;">else</span><span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// It's a new DAY!...?</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// So update the list, how many hits today, and the total.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$nip</span> = <span style="color:#0000FF;">$_SERVER</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#FF0000;">'REMOTE_ADDR'</span><span style="color:#006600; font-weight:bold;">&#93;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$today</span> = <span style="color:#CC66CC;color:#800000;">1</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$total</span>++;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$up</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"UPDATE counter SET number='"</span>.<span style="color:#0000FF;">$today</span>.<span style="color:#FF0000;">"', ipaddr='"</span>.<span style="color:#0000FF;">$nip</span>.<span style="color:#FF0000;">"', daynum='"</span>.<span style="color:#0000FF;">$date</span>.<span style="color:#FF0000;">"' WHERE logging='today'"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$up2</span> = <a href="http://www.php.net/mysql_query"><span style="color:#000066;">mysql_query</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"UPDATE counter SET number='"</span>.<span style="color:#0000FF;">$total</span>.<span style="color:#FF0000;">"' WHERE logging='total'"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// End the count.php</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Today and Total are set and done. </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>So now the $today and $total variables are set.  We will need those when we include count.php in image.php</p>
<p><strong>The Image</strong></p>
<p>So, first off, we need to pick an image.</p>
<p>I chose <img src="http://lost-whisper.info/blue_orange.png" /> not just because I didn't feel like making a new one for the tutorial, but becuase of it's coloration...?</p>
<p>So anyways, we open it up in our favorite image editor, I picked MS Paint...</p>
<p>Put the cursor where you want the text to be (the numbers or whatever).  When I did it, the location was 30, 5.  But then after coding it, you may have to change the number a bit.  I finished with 30, 3.</p>
<p><strong>Image.php</strong></p>
<p>Image.php is rather easy to make.  We have count.php and the numbers for positioning the text.</p>
<div class="igBar"><span id="lphp-5"><a href="#" onclick="javascript:showCodeTxt('php-5'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">PHP:</span>
<div id="php-5">
<div class="php">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Include count.php to log and set the variables</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#616100;">include</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"count.php"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Set our header, mine was a png, so i set image/png</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// jpeg/jpg - image/jpeg</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// gif - image/gif</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><a href="http://www.php.net/header"><span style="color:#000066;">header</span></a><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"Content-type: image/png"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Create our image from our image...</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// change png to whatever the image type is.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$image</span> = imagecreatefrompng<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#FF0000;">"blue_orange.png"</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Pick a color, 225 is the red, 154 is green, and 10 is blue</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$text</span> = imagecolorallocate<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$image</span>,<span style="color:#CC66CC;color:#800000;">255</span>, <span style="color:#CC66CC;color:#800000;">154</span>, <span style="color:#CC66CC;color:#800000;">10</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Put a string, notice the 30, 3.</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#0000FF;">$write</span> = imagestring<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$image</span>, <span style="color:#CC66CC;color:#800000;">1</span>, <span style="color:#CC66CC;color:#800000;">30</span>,<span style="color:#CC66CC;color:#800000;">3</span>, <span style="color:#0000FF;">$today</span>.<span style="color:#FF0000;">"/"</span>.<span style="color:#0000FF;">$total</span>,<span style="color:#0000FF;">$text</span><span style="color:#006600; font-weight:bold;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#FF9933; font-style:italic;">// Output the image, mine is png so yeah...</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">imagepng<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF;">$image</span><span style="color:#006600; font-weight:bold;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>And we wind up with:<br />
<img src="http://lost-whisper.info/blue_orange.php" /></p>
]]></content:encoded>
			<wfw:commentRss>http://lost-whisper.com/2006/06/26/graphical-counter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

