<?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>Adrian Callaghan`s Blog</title>
	<atom:link href="http://adriancallaghan.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://adriancallaghan.co.uk</link>
	<description>A general mix of everything</description>
	<lastBuildDate>Thu, 29 Jul 2010 12:45:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>sort a array by its value</title>
		<link>http://adriancallaghan.co.uk/sort-a-array-by-its-value/</link>
		<comments>http://adriancallaghan.co.uk/sort-a-array-by-its-value/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 12:45:07 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://adriancallaghan.co.uk/?p=577</guid>
		<description><![CDATA[To sort an array by its value, similiar to mysql sort by just use Code: usort($array, create_function('$a, $b, $sortBy="distance"', 'return strnatcmp($a[$sortBy], $b[$sortBy]);')); $array stores the array $sortBy set the key to sort by i.e Code: $array = array ( 1=>array('name'=>'me','location'=>'somewhere','distance'=>'200'), 2=>array('name'=>'you','location'=>'somewhere','distance'=>'2') ); usort($array, create_function('$a, $b, $sortBy="distance"', 'return strnatcmp($a[$sortBy], $b[$sortBy]);')); print_r($array); will result in the array [...]]]></description>
			<content:encoded><![CDATA[<p>To sort an array by its value, similiar to mysql sort by just use</p>
<div class='code_parent'>
<div class='code_title'>Code:</div>
<div class='code_child'><code>
<div class='pre_container'>
<pre>usort($array, create_function('$a, $b, $sortBy="distance"', 'return strnatcmp($a[$sortBy], $b[$sortBy]);'));</pre>
</div>
<p></code></div>
</div>
<p>$array stores the array<br />
$sortBy set the key to sort by</p>
<p>i.e</p>
<div class='code_parent'>
<div class='code_title'>Code:</div>
<div class='code_child'><code>
<div class='pre_container'>
<pre>$array = array (
    1=>array('name'=>'me','location'=>'somewhere','distance'=>'200'),
    2=>array('name'=>'you','location'=>'somewhere','distance'=>'2')
    );

usort($array, create_function('$a, $b, $sortBy="distance"', 'return strnatcmp($a[$sortBy], $b[$sortBy]);'));
print_r($array);</pre>
</div>
<p></code></div>
</div>
<p>will result in the array being re-ordered with location 2 now being in location 1 (preserving the keys)</p>
]]></content:encoded>
			<wfw:commentRss>http://adriancallaghan.co.uk/sort-a-array-by-its-value/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>styling form buttons with divs</title>
		<link>http://adriancallaghan.co.uk/styling-form-buttons-with-divs/</link>
		<comments>http://adriancallaghan.co.uk/styling-form-buttons-with-divs/#comments</comments>
		<pubDate>Fri, 28 Aug 2009 15:57:46 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://adriancallaghan.co.uk/?p=541</guid>
		<description><![CDATA[Styling a button inside a form with multiple div`s to achieve a curved button with click events etc, can be done relatively easy with the use of javascript. For example: function submitform(){ document.mainForm.submit(); } document.write(''); document.write(' '); document.write(' '); document.write('submit'); document.write(' '); document.write(' '); document.write(''); #container { width:200px; height:40px; padding:10px; color:#323232; display:block; background:#E4E4E4; border:4px solid [...]]]></description>
			<content:encoded><![CDATA[<p>Styling a button inside a form with multiple div`s to achieve a curved button with click events etc, can be done relatively easy with the use of javascript.</p>
<link rel="stylesheet" type="text/css" href="http://adriancallaghan.co.uk/wp-content/plugins/clikstats/ck.php?Ck_id=541&Ck_lnk=http://adriancallaghan.co.uk/demos/button/button.css" />
<div id="container">
For example:</p>
<form method="post" action="" name="mainForm">
<noscript><br />
<input type="submit" name="submit"></noscript><br />
<script type="text/javascript">				
function submitform(){
document.mainForm.submit();
}
document.write('<a href="http://adriancallaghan.co.uk/wp-content/plugins/clikstats/ck.php?Ck_id=541&Ck_lnk=javascript:submitform();" style="text-decoration:none; color:#fff; font-weight:bold;">');
document.write('
<div id="buyButtonMid">');
document.write('
<div id="buyButtonLeft"></div>
<p>');
document.write('submit');
document.write('
<div id="buyButtonRight"></div>
<p>');
document.write('</p></div>
<p>');
document.write('</a>');
</script><br />
</form>
</div>
<style>
#container {
	width:200px;
	height:40px;
	padding:10px;
	color:#323232;
	display:block;
	background:#E4E4E4;
	border:4px solid #C8C8C8;
	}</p>
<p>/* buy button */
#buyButtonRight{
	width:16px;
	height:44px;
	display:block;
	position:absolute;
	top:0;
	right:0;
	cursor:pointer;
	}</p>
<p>#buyButtonLeft{
	width:16px;
	height:44px;
	display:block;
	position:absolute;
	top:0;
	left:0;
	cursor:pointer;
	}</p>
<p>#buyButtonMid{
	height:24px;
	min-width:20px;
	/*max-width:300px;*/
	padding:13px 20px 7px 20px;
	display:block;
	position:relative;
	float:left;
	cursor:pointer;
	color:#ffffff; 
	font-size:13px; 
	text-decoration:none;
	}</p>
<p>/* normal */
#buyButtonLeft{background:url('http://adriancallaghan.co.uk/demos/button/add2bas_left.jpg');}	
#buyButtonMid{background:url('http://adriancallaghan.co.uk/demos/button/add2bas_mid.jpg');}	
#buyButtonRight{background:url('http://adriancallaghan.co.uk/demos/button/add2bas_right.jpg');}</p>
<p>/* hover */
#buyButtonMid:hover #buyButtonLeft{background:url('http://adriancallaghan.co.uk/demos/button/add2bas_left_hover.jpg');}
#buyButtonMid:hover {background:url('http://adriancallaghan.co.uk/demos/button/add2bas_mid_hover.jpg');}
#buyButtonMid:hover #buyButtonRight{background:url('http://adriancallaghan.co.uk/demos/button/add2bas_right_hover.jpg');}</p>
<p>/* click */
#buyButtonMid:active #buyButtonLeft{background:url('http://adriancallaghan.co.uk/demos/button/add2bas_left_click.jpg') no-repeat;}
#buyButtonMid:active {background:url('http://adriancallaghan.co.uk/demos/button/add2bas_mid_click.jpg');}
#buyButtonMid:active #buyButtonRight{background:url('http://adriancallaghan.co.uk/demos/button/add2bas_right_click.jpg');}
</style>
<p>firstly lets take a look at our raw code</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form method=&quot;post&quot; action=&quot;&quot;&gt;
      &lt;input type=&quot;submit&quot; name=&quot;submit&quot;&gt;
&lt;/form&gt;</pre></div></div>

<p>Next we place the button within no script tags, so it only displays if javascript is switched off, so that<br />
non javascript enabled browsers can still submit.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form method=&quot;post&quot; action=&quot;&quot;&gt;
      &lt;noscript&gt;
          &lt;input type=&quot;submit&quot; name=&quot;submit&quot;&gt;
      &lt;/noscript&gt;
&lt;/form&gt;</pre></div></div>

<p>Now we add the javascript styled button</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
&lt;form method=&quot;post&quot; action=&quot;&quot; name=&quot;mainForm&quot;&gt;
      &lt;noscript&gt;
          &lt;input type=&quot;submit&quot; name=&quot;submit&quot;&gt;
      &lt;/noscript&gt;
	<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;!--</span>					
&nbsp;
	<span style="color: #006600; font-style: italic;">// do the submission</span>
	<span style="color: #003366; font-weight: bold;">function</span> submitform<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		document.<span style="color: #660066;">mainForm</span>.<span style="color: #660066;">submit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #006600; font-style: italic;">// print the button</span>
	document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;a href=&quot;javascript:submitform();&quot; style=&quot;text-decoration:none; color:#fff; font-weight:bold;&quot;&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div id=&quot;buyButtonMid&quot;&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div id=&quot;buyButtonLeft&quot;&gt;&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'submit'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;div id=&quot;buyButtonRight&quot;&gt;&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;/div&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	document.<span style="color: #000066; font-weight: bold;">write</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;/a&gt;'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
	<span style="color: #006600; font-style: italic;">// --&gt;</span>
&nbsp;
	<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span>
&lt;/form&gt;</pre></div></div>

<p>Then style your button accordingly with your css,</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* buy button */</span>
<span style="color: #cc00cc;">#buyButtonRight</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">44px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#buyButtonLeft</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">44px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #cc00cc;">#buyButtonMid</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">24px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">min-width</span><span style="color: #00AA00;">:</span><span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #808080; font-style: italic;">/*max-width:300px;*/</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">13px</span> <span style="color: #933;">20px</span> <span style="color: #933;">7px</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#ffffff</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">font-size</span><span style="color: #00AA00;">:</span><span style="color: #933;">13px</span><span style="color: #00AA00;">;</span> 
	<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">/* normal */</span>
<span style="color: #cc00cc;">#buyButtonLeft</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/add2bas_left.jpg'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>	
<span style="color: #cc00cc;">#buyButtonMid</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/add2bas_mid.jpg'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>	
<span style="color: #cc00cc;">#buyButtonRight</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/add2bas_right.jpg'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* hover */</span>
<span style="color: #cc00cc;">#buyButtonMid</span><span style="color: #3333ff;">:hover </span><span style="color: #cc00cc;">#buyButtonLeft</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/add2bas_left_hover.jpg'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#buyButtonMid</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/add2bas_mid_hover.jpg'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#buyButtonMid</span><span style="color: #3333ff;">:hover </span><span style="color: #cc00cc;">#buyButtonRight</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/add2bas_right_hover.jpg'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* click */</span>
<span style="color: #cc00cc;">#buyButtonMid</span><span style="color: #3333ff;">:active </span><span style="color: #cc00cc;">#buyButtonLeft</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/add2bas_left_click.jpg'</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#buyButtonMid</span><span style="color: #3333ff;">:active </span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/add2bas_mid_click.jpg'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#buyButtonMid</span><span style="color: #3333ff;">:active </span><span style="color: #cc00cc;">#buyButtonRight</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'images/add2bas_right_click.jpg'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Job done <img src='http://adriancallaghan.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://adriancallaghan.co.uk/styling-form-buttons-with-divs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>wordpress comment count as a button</title>
		<link>http://adriancallaghan.co.uk/wordpress-comment-count-as-a-button/</link>
		<comments>http://adriancallaghan.co.uk/wordpress-comment-count-as-a-button/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 13:46:56 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://adriancallaghan.co.uk/?p=533</guid>
		<description><![CDATA[Styling the wordpress comment count as a button/icon etc can be tricky because the normal call to the comments 1 comments_popup_link&#40;__&#40;'Comments (0)'&#41;, __&#40;'Comments (1)'&#41;, __&#40;'Comments (%)'&#41;&#41;; formats the output as an anchor point with the correct link, alt tags etc already set up. So in order to intercept this and then add you own anchor [...]]]></description>
			<content:encoded><![CDATA[<p>Styling the wordpress comment count as a button/icon etc can be tricky because the normal call to the comments</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">comments_popup_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comments (0)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comments (1)'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comments (%)'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>formats the output as an anchor point with the correct link, alt tags etc already set up.</p>
<p>So in order to intercept this and then add you own anchor point with divs/imagery etc you need to make a custom request</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #666666; font-style: italic;">// SQL</span>
<span style="color: #000088;">$SQL</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT COUNT(*) AS Count FROM <span style="color: #006699; font-weight: bold;">$wpdb-&gt;comments</span> WHERE comment_approved='1'&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$SQL</span><span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;AND comment_post_ID='&quot;</span><span style="color: #339933;">.</span><span style="color: #990000;">intval</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;'&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Sort the array into a string prefixed with 'Comments '</span>
<span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$comments</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQL</span><span style="color: #339933;">,</span> ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 	
<span style="color: #000088;">$comments</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'Comments ('</span><span style="color: #339933;">.</span><span style="color: #000088;">$comments</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Count'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">')'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// generate the alt and title tags</span>
<span style="color: #000088;">$alt</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'Comment on '</span><span style="color: #339933;">.</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">post_title</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// echo the button if this is not a single and not a page</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>is_single<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// anchor open</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;a href=&quot;'</span><span style="color: #339933;">.</span>get_permalink<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; alt=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$alt</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot; title=&quot;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$alt</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&quot;&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// complex formatting rules for the comment pop up, go here</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$comments</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// anchor close</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/a&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>The above does exactly the same, formats the link etc, but now you can access the anchor point directly and format it your own way.</p>
]]></content:encoded>
			<wfw:commentRss>http://adriancallaghan.co.uk/wordpress-comment-count-as-a-button/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ftp open in explorer by default in windows</title>
		<link>http://adriancallaghan.co.uk/ftp-open-in-explorer-by-default-in-windows/</link>
		<comments>http://adriancallaghan.co.uk/ftp-open-in-explorer-by-default-in-windows/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 09:25:24 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://adriancallaghan.co.uk/?p=527</guid>
		<description><![CDATA[How to make explorer open by default when opening an ftp connection, I found can be easy.. I needed to make IE6 style FTP access without the extra pop up step, from a desktop shortcut at work and after much googling, and messing with the registery, attempting to make an ftp site open immediatly in [...]]]></description>
			<content:encoded><![CDATA[<p>How to make explorer open by default when opening an ftp connection, I found can be easy..</p>
<p>I needed to make IE6 style FTP access without the extra pop up step, from a desktop shortcut at work and after much googling, and messing with the registery, attempting to make an ftp site open immediatly in explorer without the main browser opening (pre IE7), I found it can be simply done like this.</p>
<p>1. create a bat file (open notepad, save the file with the affix .bat, making sure .txt is not selected in the dropdown)<br />
2. in the batch file add</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="dos" style="font-family:monospace;">start explorer ftp://USERNAME:PASSWORD<span style="color: #33cc33;">@</span>FTP_SERVER_ADDRESS</pre></td></tr></table></div>

<p>3. add the shortcut to the desktop, and style the icon</p>
<p>Now when the user clicks the shortcut, voila IE6 style FTP access without the extra step, much easier than poking around with the registery <img src='http://adriancallaghan.co.uk/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://adriancallaghan.co.uk/ftp-open-in-explorer-by-default-in-windows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Online md5 hasher</title>
		<link>http://adriancallaghan.co.uk/online-md5-hasher/</link>
		<comments>http://adriancallaghan.co.uk/online-md5-hasher/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 09:41:00 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[applications]]></category>

		<guid isPermaLink="false">http://adriancallaghan.co.uk/?p=520</guid>
		<description><![CDATA[MD5 Hasher, To generate an md5 hash just enter your text below .result { color:#000000; background:#677E64; font-size:15px; display:block; width:250px; height:40px; text-align:center; overflow:wrap; border:1px solid #94B89E; margin:20px 5px; padding:10px; }]]></description>
			<content:encoded><![CDATA[<p>MD5 Hasher,</p>
<p>To generate an md5 hash just enter your text below</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://adriancallaghan.co.uk/online-md5-hasher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How many days old am I?</title>
		<link>http://adriancallaghan.co.uk/how-many-days-old-am-i/</link>
		<comments>http://adriancallaghan.co.uk/how-many-days-old-am-i/#comments</comments>
		<pubDate>Thu, 28 May 2009 20:03:02 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[applications]]></category>

		<guid isPermaLink="false">http://adriancallaghan.co.uk/?p=515</guid>
		<description><![CDATA[How many days old are you? Well just fill in your birthday below to find out! .result { color:#000000; background:#677E64; font-size:15px; display:block; width:250px; height:40px; text-align:center; overflow:wrap; border:1px solid #94B89E; margin:20px 5px; padding:10px; } 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th 11th 12th 13th 14th 15th 16th 17th 18th 19th 20th 21st 22nd [...]]]></description>
			<content:encoded><![CDATA[<p>How many days old are you?</p>
<p>Well just fill in your birthday below to find out!</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://adriancallaghan.co.uk/how-many-days-old-am-i/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>What is html?</title>
		<link>http://adriancallaghan.co.uk/what-is-html/</link>
		<comments>http://adriancallaghan.co.uk/what-is-html/#comments</comments>
		<pubDate>Thu, 30 Apr 2009 16:00:44 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://adriancallaghan.co.uk/?p=383</guid>
		<description><![CDATA[What is HTML and how does it work? In simple terms and to just introduce HTML (and not technical), most pages that people view on the internet are simply text files, that are being displayed a special way within a browser, they simply have the affix .html instead of .txt. Whatever your browser (Internet explorer, [...]]]></description>
			<content:encoded><![CDATA[<p>What is HTML and how does it work?</p>
<p>In simple terms and to just introduce HTML (and not technical), most pages that people view on the internet are simply text files, that are being displayed a special way within a browser, they simply have the affix .html instead of .txt.</p>
<p>Whatever your browser (Internet explorer, firefox, opera, safari etc) they will attempt to render the text document according to some rules contained within it.</p>
<p>The rules contained within the document are in the form of tags placed within a < and a >.</p>
<p>These tags specify the rules or &#8220;markup&#8221; language for the way the text should be displayed.</p>
<p>The tags (generally) must have an equal amount of opening and closing tags, and must be closed in order.</p>
<p>There are many different tags, with many different uses.</p>
<p>For example, to render text as a header, the tag would be &lt;h1&gt;<span style="font-size:10pt; font-weight:bold;">HEADER TEXT</span>&lt;/h1&gt;.</p>
<p>The tagging or, &#8220;markup language&#8221; explains the latter part of the acroynm HTML or &#8220;Hyper&#8221;, &#8220;Text&#8221;, &#8220;<b>Markup</b>&#8220;, &#8220;<b>Language</b>&#8220;.</p>
<p><span id="more-383"></span><br />
The foremost &#8220;Hyper&#8221; and &#8220;Text&#8221; relates to pages hyper linking to one another by clicking on special text.</p>
<p>Hyper text is created by embedding text, with an associated URL by use of a special tag (known as an anchor point).</p>
<p>The anchor point displays the text to the viewer but however when it is clicked it will redirect the browser to a new defined location, &#8220;Hyper&#8221;, &#8220;Text&#8221; through &#8220;Markup&#8221;, &#8220;Language&#8221;.</p>
<p>An anchor point would look something like &lt;a href=&#8221;URL&#8221;&gt;TEXT THAT IS CLICKABLE&lt;/a&gt;  </p>
<p>However, browsers do expect some basic rules to be followed relating to the way in which the HTML appears.</p>
<p>There are many more advanced rules, which are beyond the scope of this basic introduction, but the most important are the document consist of a Head and Body wrapped in a html root tag.</p>
<p>The head tells the browser information such as the title of the page, and the body would be the content, but however the page would display without this formatting.</p>
<p>For example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
       &lt;head&gt;
               &lt;title&gt;Hello World!&lt;/title&gt;
       &lt;/head&gt;
       &lt;body&gt;
               &lt;h1&gt;Hello World!&lt;/h1&gt;
       &lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://adriancallaghan.co.uk/what-is-html/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>WordPress blog to MU</title>
		<link>http://adriancallaghan.co.uk/manually-upgrade-a-wordpress-blog-to-mu-multiuser/</link>
		<comments>http://adriancallaghan.co.uk/manually-upgrade-a-wordpress-blog-to-mu-multiuser/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 14:39:49 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://adriancallaghan.co.uk/?p=368</guid>
		<description><![CDATA[Upgrading to wordpress MU manually from an old blog. At work I had to update an old wordpress installation from 2.3.2 all the way up to the latest version of WordPress Mu (Multi User). I documented the method I used and placed it below here. If you do decide to do this it is done [...]]]></description>
			<content:encoded><![CDATA[<p>Upgrading to wordpress MU manually from an old blog.<br />
<br />
At work I had to update an old wordpress installation from 2.3.2 all the way up to the latest version of WordPress Mu (Multi User).<br />
<br />
I documented the method I used and placed it below here.<br />
<b>If you do decide to do this it is done entirely at your <u>own</u> risk.<br />
<font color="red">ALWAYS MAKE A BACKUP FIRST</font><br />
</b><br />
</p>
<h4>Stage 1</h4>
<p>Install Mu on its own database alongside your existing installation and database, within its own directory in the normal way.</p>
<h4>Stage 2</h4>
<p>Move the data across from Mu performing an upgrade, keeping all the data intact and wordpress Mu functioning correctly.</p>
<h5>How this is done</h5>
<p><span id="more-368"></span><br />
1. On your old blog`s database rename the following tables</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="mysql" style="font-family:monospace;">	<span style="color: #990099; font-weight: bold;">from</span>				       <span style="color: #990099; font-weight: bold;">to</span>
	<span style="color: #CC0099;">-----------------------------------------------------------------</span>
	wp_comments		       wp_1_comments
	wp_links			       wp_1_links
	wp_options		       wp_1_options
	wp_postmeta		       wp_1_postmeta
        wp_posts		               wp_1_posts
	wp_terms			       wp_1_terms
	wp_term_relationships       wp_1_term_relationships
	wp_term_taxonomy	       wp_1_term_taxonomy</pre></td></tr></table></div>

<p>2. Copy only these tables across from the MU database to the old blog database.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="mysql" style="font-family:monospace;">	wp_blogs
	wp_blog_versions
   <span style="color: #CC0099;">--&gt;</span>	wp_posts 		<span style="color: #FF00FF;">&#40;</span>THIS CAN BE OVER WRITTEN BECAREFULL<span style="color: #FF00FF;">&#41;</span>
	wp_registration_log
	wp_signups
	wp_site
	wp_site_categories</pre></td></tr></table></div>

<p>3. Alter the table wp_users in the old database by adding the following fields to its structure</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="mysql" style="font-family:monospace;">	<span style="color: #000099;">Field</span>		        <span style="color: #990099; font-weight: bold;">Type</span>		  <span style="color: #000099;">Collation</span>	  Attributes	<span style="color: #9900FF; font-weight: bold;">Null</span>   	<span style="color: #990099; font-weight: bold;">default</span>   Extra
	<span style="color: #CC0099;">----------------------------------------------------------------------------------------------------------------------</span>
	spam 		<span style="color: #999900; font-weight: bold;">tinyint</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">2</span><span style="color: #FF00FF;">&#41;</span>					        <span style="color: #990099; font-weight: bold;">No</span>	        <span style="color: #008080;">0</span>
	deleted		<span style="color: #999900; font-weight: bold;">tinyint</span><span style="color: #FF00FF;">&#40;</span><span style="color: #008080;">2</span><span style="color: #FF00FF;">&#41;</span>					        <span style="color: #990099; font-weight: bold;">No</span>	        <span style="color: #008080;">0</span></pre></td></tr></table></div>

<p>4. Add the following information into the table wp_1_options in the old database</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
</pre></td><td class="code"><pre class="mysql" style="font-family:monospace;">	option_id	blog_id		option_name			option_value			        autoload
	<span style="color: #CC0099;">--------------------------------------------------------------------------------------------------------------------------------------------</span>
	<span style="color: #008080;">75</span>		<span style="color: #008080;">0</span>		avatar_default			        mystery				        yes
	<span style="color: #008080;">68</span>		<span style="color: #008080;">0</span>		avatar_rating			        G				                yes
	<span style="color: #008080;">84</span>		<span style="color: #008080;">0</span> 		close_comments_days_old		<span style="color: #008080;">14</span>				                yes
	<span style="color: #008080;">83</span>		<span style="color: #008080;">0</span>		close_comments_for_old_posts	<span style="color: #008080;">0</span>				                yes
	<span style="color: #008080;">88</span>		<span style="color: #008080;">0</span> 		comments_per_page		        <span style="color: #008080;">50</span>				                yes
	<span style="color: #008080;">116</span>		<span style="color: #008080;">0</span>		current_theme			        <span style="color: #FF00FF;">&#40;</span>the <span style="color: #990099; font-weight: bold;">value</span> <span style="color: #990099; font-weight: bold;">from</span> the <span style="color: #990099; font-weight: bold;">database</span><span style="color: #FF00FF;">&#41;</span>	yes
	<span style="color: #008080;">107</span>		<span style="color: #008080;">0</span>		dashboard_widget_options   	<span style="color: #FF00FF;">&#40;</span>the <span style="color: #990099; font-weight: bold;">value</span> <span style="color: #990099; font-weight: bold;">from</span> the <span style="color: #990099; font-weight: bold;">database</span><span style="color: #FF00FF;">&#41;</span>	yes
	<span style="color: #008080;">97</span>		<span style="color: #008080;">0</span>		dismissed_update_core		a:<span style="color: #008080;">0</span>:<span style="color: #FF00FF;">&#123;</span><span style="color: #FF00FF;">&#125;</span>				                yes
	<span style="color: #008080;">76</span>		<span style="color: #008080;">0</span>		enable_app			        <span style="color: #008080;">0</span>				                yes
	<span style="color: #008080;">77</span>		<span style="color: #008080;">0</span>		enable_xmlrpc			        <span style="color: #008080;">0</span>				                yes
	<span style="color: #008080;">99</span>		<span style="color: #008080;">0</span>		fileupload_url			        <span style="color: #FF00FF;">&#40;</span>the <span style="color: #990099; font-weight: bold;">value</span> <span style="color: #990099; font-weight: bold;">from</span> the <span style="color: #990099; font-weight: bold;">database</span><span style="color: #FF00FF;">&#41;</span>	yes
	<span style="color: #008080;">82</span>		<span style="color: #008080;">0</span>		image_default_align						                        yes
	<span style="color: #008080;">80</span>		<span style="color: #008080;">0</span>		image_default_link_type		file				                yes
	<span style="color: #008080;">81</span>		<span style="color: #008080;">0</span>		image_default_size						                        yes
	<span style="color: #008080;">79</span>		<span style="color: #008080;">0</span>		large_size_h			        <span style="color: #008080;">1024</span>				                yes	
	<span style="color: #008080;">78</span>		<span style="color: #008080;">0</span>		large_size_w			        <span style="color: #008080;">1024</span>				                yes
	<span style="color: #008080;">74</span>		<span style="color: #008080;">0</span>		medium_size_h			        <span style="color: #008080;">300</span>				                yes
	<span style="color: #008080;">73</span>		<span style="color: #008080;">0</span>		medium_size_w			        <span style="color: #008080;">300</span>				                yes
	<span style="color: #008080;">108</span>		<span style="color: #008080;">0</span>		nonce_salt			                <span style="color: #FF00FF;">&#40;</span>the <span style="color: #990099; font-weight: bold;">value</span> <span style="color: #990099; font-weight: bold;">from</span> the <span style="color: #990099; font-weight: bold;">database</span><span style="color: #FF00FF;">&#41;</span>	yes
	<span style="color: #008080;">87</span>		<span style="color: #008080;">0</span>		page_comments			<span style="color: #008080;">1</span>				                yes
	<span style="color: #008080;">100</span>		<span style="color: #008080;">0</span>		post_count			        <span style="color: #008080;">1</span>				                yes
	<span style="color: #008080;">61</span>		<span style="color: #008080;">0</span>		random_seed			        <span style="color: #FF00FF;">&#40;</span>the <span style="color: #990099; font-weight: bold;">value</span> <span style="color: #990099; font-weight: bold;">from</span> the <span style="color: #990099; font-weight: bold;">database</span><span style="color: #FF00FF;">&#41;</span>	yes
	<span style="color: #008080;">67</span>		<span style="color: #008080;">0</span>		show_avatars			        <span style="color: #008080;">1</span>				                yes
	<span style="color: #008080;">92</span>		<span style="color: #008080;">0</span>		sticky_posts			        a:<span style="color: #008080;">0</span>:<span style="color: #FF00FF;">&#123;</span><span style="color: #FF00FF;">&#125;</span>				                yes
	<span style="color: #008080;">85</span>		<span style="color: #008080;">0</span>		thread_comments			<span style="color: #008080;">0</span>				                yes
	<span style="color: #008080;">86</span>		<span style="color: #008080;">0</span>		thread_comments_depth		<span style="color: #008080;">5</span>				                yes
	<span style="color: #008080;">72</span>		<span style="color: #008080;">0</span>		thumbnail_crop			        <span style="color: #008080;">1</span>				                yes
	<span style="color: #008080;">71</span>		<span style="color: #008080;">0</span>		thumbnail_size_h		        <span style="color: #008080;">150</span>				                yes
	<span style="color: #008080;">70</span>		<span style="color: #008080;">0</span>		thumbnail_size_w		        <span style="color: #008080;">150</span>				                yes
	<span style="color: #008080;">106</span>		<span style="color: #008080;">0</span>		update_themes			        <span style="color: #FF00FF;">&#40;</span>the <span style="color: #990099; font-weight: bold;">value</span> <span style="color: #990099; font-weight: bold;">from</span> the <span style="color: #990099; font-weight: bold;">database</span><span style="color: #FF00FF;">&#41;</span>	yes
	<span style="color: #008080;">69</span>		<span style="color: #008080;">0</span>		upload_url_path							                        yes
	<span style="color: #008080;">91</span>		<span style="color: #008080;">0</span>		use_ssl				        <span style="color: #008080;">0</span>				                yes
	<span style="color: #008080;">95</span>		<span style="color: #008080;">0</span>		widget_rss			                a:<span style="color: #008080;">0</span>:<span style="color: #FF00FF;">&#123;</span><span style="color: #FF00FF;">&#125;</span>				                yes
	<span style="color: #008080;">94</span>		<span style="color: #008080;">0</span>		widget_text			        a:<span style="color: #008080;">0</span>:<span style="color: #FF00FF;">&#123;</span><span style="color: #FF00FF;">&#125;</span>				                yes
	<span style="color: #008080;">102</span>		<span style="color: #008080;">0</span>		WPLANG								                        yes
	<span style="color: #008080;">98</span>		<span style="color: #008080;">0</span>		wp_1_user_roles			<span style="color: #FF00FF;">&#40;</span>the <span style="color: #990099; font-weight: bold;">value</span> <span style="color: #990099; font-weight: bold;">from</span> the <span style="color: #990099; font-weight: bold;">database</span><span style="color: #FF00FF;">&#41;</span>	yes</pre></td></tr></table></div>

<p>5. alter the value of upload_path in wp_1_options in the old database to wp-content/blogs.dir/1/files</p>
<h2>The blog will now be active</h2>
<p>&#8230;but the back office is broken!, to fix this&#8230;.</p>
<p>6. in wp_usermeta change every entry of wp_capabilities to wp_1_capabilities (use the mysql below)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">UPDATE</span> wp_usermeta <span style="color: #990099; font-weight: bold;">SET</span> meta_key<span style="color: #CC0099;">=</span><span style="color: #008000;">'wp<span style="color: #008080; font-weight: bold;">_</span>1<span style="color: #008080; font-weight: bold;">_</span>capabilities'</span> <span style="color: #990099; font-weight: bold;">WHERE</span> meta_key<span style="color: #CC0099;">=</span><span style="color: #008000;">'wp<span style="color: #008080; font-weight: bold;">_</span>capabilities'</span></pre></td></tr></table></div>

<p>7. create some extra fields based upon the user (run the php code below)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// custom code for upgrade</span>
&nbsp;
<span style="color: #990000;">list</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$maxId</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'SELECT max(umeta_id) AS startPoint FROM wp_usermeta'</span><span style="color: #339933;">,</span> ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'SELECT ID FROM wp_users'</span><span style="color: #339933;">,</span> ARRAY_A<span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">AS</span> <span style="color: #000088;">$userId</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;h3&gt;Updating user: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$userId</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/h3&gt;&lt;p&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// execute all the querys</span>
	<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$queryNumber</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$queryNumber</span><span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$queryNumber</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">:</span> 
				<span style="color: #000088;">$SQL1</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (&quot;</span><span style="color: #339933;">;</span> 
				<span style="color: #000088;">$SQL2</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$userId</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;, 'comment_shortcuts', 'false');&quot;</span><span style="color: #339933;">;</span> 
				<span style="color: #000088;">$queryNumber</span><span style="color: #339933;">++;</span> 
				<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> 
				<span style="color: #000088;">$SQL1</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (&quot;</span><span style="color: #339933;">;</span> 
				<span style="color: #000088;">$SQL2</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$userId</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;, 'admin_color', 'fresh');&quot;</span><span style="color: #339933;">;</span> 
				<span style="color: #000088;">$queryNumber</span><span style="color: #339933;">++;</span>
				<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">2</span><span style="color: #339933;">:</span> 
				<span style="color: #000088;">$SQL1</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;INSERT INTO wp_usermeta (umeta_id, user_id, meta_key, meta_value) VALUES (&quot;</span><span style="color: #339933;">;</span> 
				<span style="color: #000088;">$SQL2</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;, &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$userId</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'ID'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;, 'source_domain', 'YOURBLOGDOMAIN');&quot;</span><span style="color: #339933;">;</span> 
				<span style="color: #000088;">$queryNumber</span><span style="color: #339933;">++;</span>
				<span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">default</span><span style="color: #339933;">:</span>
				<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Query out of bounds exception:  '</span><span style="color: #339933;">.</span><span style="color: #000088;">$queryNumber</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// check the slot is available</span>
		<span style="color: #000088;">$check</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SELECT * FROM wp_usermeta WHERE umeta_id='</span><span style="color: #339933;">.</span><span style="color: #000088;">$maxId</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'startPoint'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">empty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$check</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
			<span style="color: #000088;">$maxId</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'startPoint'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">++;</span> 
			<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Incrementing to: '</span><span style="color: #339933;">.</span><span style="color: #000088;">$maxId</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'startPoint'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$check</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SELECT * FROM wp_usermeta WHERE umeta_id='</span><span style="color: #339933;">.</span><span style="color: #000088;">$maxId</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'startPoint'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> ARRAY_A<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000088;">$SQL</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$SQL1</span><span style="color: #339933;">.</span><span style="color: #000088;">$maxId</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'startPoint'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #000088;">$SQL2</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Executing query '</span><span style="color: #339933;">.</span><span style="color: #000088;">$queryNumber</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'       : '</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQL</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'Success'</span><span style="color: #339933;">:</span> <span style="color: #0000ff;">'Failed'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;br /&gt;'</span><span style="color: #339933;">;</span>		
		<span style="color: #009900;">&#125;</span>
	<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>8. point the MU config.php to the old database, you will need to change the permissions from 644 to 666 use CHMOD<br />
    or duplicate the config file, alter it, rename the old config file, and then rename the new file as config.php</p>
<p>9. Log into the back office goto to settings->permalinks and click save, your posts/pages can now be found</p>
<p>Your upgrade should now be complete and you can go ahead and delete the MU database installation, not your old but now upgraded database.</p>
<p>I will be happy to answer any questions, and comments as always, are welcome</p>
<p>Additionally:<br />
Ensure that both the field umeta_id in table wp_usermeta and the field ID in table wp_users are set to auto_increment.</p>
]]></content:encoded>
			<wfw:commentRss>http://adriancallaghan.co.uk/manually-upgrade-a-wordpress-blog-to-mu-multiuser/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Table pagination example PHP</title>
		<link>http://adriancallaghan.co.uk/pagination-php/</link>
		<comments>http://adriancallaghan.co.uk/pagination-php/#comments</comments>
		<pubDate>Sun, 08 Feb 2009 20:58:06 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://adriancallaghan.co.uk/?p=330</guid>
		<description><![CDATA[Table Pagination in PHP can be easily achieved with this function. It is designed to be used in conjunction with the database class found here but can be used standalone with any suitable array. The idea of this function is to quickly output the results of a multi-dimensioned associative array, with the minimuim of fuss. [...]]]></description>
			<content:encoded><![CDATA[<p>Table Pagination in PHP can be easily achieved with <a href="http://adriancallaghan.co.uk/wp-content/plugins/clikstats/ck.php?Ck_id=330&Ck_lnk=http://adriancallaghan.co.uk/wp-content/downloads/paginate_function.zip">this</a> function.</p>
<p>It is designed to be used in conjunction with the database class found <a href="http://adriancallaghan.co.uk/wp-content/plugins/clikstats/ck.php?Ck_id=330&Ck_lnk=http://adriancallaghan.co.uk/database-class-for-php/">here</a> but can be used standalone with any suitable array.</p>
<p>The idea of this function is to quickly output the results of a multi-dimensioned associative array, with the minimuim of fuss.<br />
This is ideal for repetitive back office dutys, but however, there are arguments which can be passed depending upon the level of control required to change the functionality or format.</p>
<p>A beginners step by step example can be found <a href="http://adriancallaghan.co.uk/wp-content/plugins/clikstats/ck.php?Ck_id=330&Ck_lnk=http://adriancallaghan.co.uk/demos/table_pagination/">here</a><br />
and the source code <a href="http://adriancallaghan.co.uk/wp-content/plugins/clikstats/ck.php?Ck_id=330&Ck_lnk=http://adriancallaghan.co.uk/wp-content/downloads/paginate_function.zip">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://adriancallaghan.co.uk/pagination-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Database class for php</title>
		<link>http://adriancallaghan.co.uk/database-class-for-php/</link>
		<comments>http://adriancallaghan.co.uk/database-class-for-php/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 21:51:12 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://adriancallaghan.co.uk/?p=300</guid>
		<description><![CDATA[Database class for php $dataBase = new DB(); (instaniates the database ready for CRUD) $result = $dataBase->getQuery(&#8216;SELECT * FROM FOO WHERE bar=1&#8242;); ($result contains a multidimensional associative array) $id = $dataBase->setQuery(&#8216;DELETE FROM FOO WHERE bar=1&#8242;); ($id contains the row id of the last update, can be left out) To settup the class 1 2 3 [...]]]></description>
			<content:encoded><![CDATA[<p>Database class for php</p>
<p>$dataBase = new DB();<br />
(instaniates the database ready for CRUD)</p>
<p>$result = $dataBase->getQuery(&#8216;SELECT * FROM FOO WHERE bar=1&#8242;);<br />
($result contains a multidimensional associative array)</p>
<p>$id = $dataBase->setQuery(&#8216;DELETE FROM FOO WHERE bar=1&#8242;);<br />
($id contains the row id of the last update, can be left out)</p>
<p>To settup the class</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// database</span>
<span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'HOST'</span><span style="color: #339933;">,</span>		<span style="color: #0000ff;">'localhost'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'NAME'</span><span style="color: #339933;">,</span>		<span style="color: #0000ff;">'NAME_OF_DATABASE'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'USER'</span><span style="color: #339933;">,</span>		<span style="color: #0000ff;">'USER_NAME'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'PASS'</span><span style="color: #339933;">,</span>		<span style="color: #0000ff;">'PASSWORD'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Error messages</span>
<span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'ERRS'</span><span style="color: #339933;">,</span>		<span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Meaningfull error messages on or off (mainly SQL related)</span>
<span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'MESSAGE'</span><span style="color: #339933;">,</span>		<span style="color: #0000ff;">'The server encountered an internal error'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// Default message</span>
<span style="color: #990000;">define</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'admin_email'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'someone@somewhere.com'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// email errors to</span></pre></td></tr></table></div>

<p>Errors can be set to display on or off (uses a generic message) it then emails full details to the administrator of the fault.</p>
<p>It can be downloaded from <a href="http://adriancallaghan.co.uk/wp-content/plugins/clikstats/ck.php?Ck_id=300&Ck_lnk=http://adriancallaghan.co.uk/wp-content/downloads/dataBase.zip">here</a></p>
<p>Code below</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> 
<span style="color: #000000; font-weight: bold;">class</span> DB<span style="color: #009900;">&#123;</span>
<span style="color: #666666; font-style: italic;">/* 
DESCRIPTION:	Object class, Handles all database requests and returns content accordingly
&nbsp;
WRITER:			Adrian Callaghan 120808
INSTANIATION:	new DB()                    requires HOST,NAME,USER,PASS,ERRS,MESSAGE values to be set prior (config)
&nbsp;
&nbsp;
API:
&nbsp;
	MODIFIERS:
				setStateClose()				// sets the mySql connection to close
				setQuery($arg)				// executes a query without returning any results, used for insert, create etc,  
											// returns the ID of the last auto-increment
				setErrMessage($err)			// displays and emails, the sql error
				setDataBase($database)		// sets dataBase, leave arg blank to set back to the default 
	ACCESSORS:
				getQuery($arg)				// executes sql query from $arg and returns result as a '2d assoc array'
				getStateOpen()				// returns details about the currently open connection
				*/</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$mySqlHost</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #000088;">$dataBase</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mySqlHost</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_connect</span><span style="color: #009900;">&#40;</span>HOST<span style="color: #339933;">,</span> USER<span style="color: #339933;">,</span> PASS<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mySqlHost</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setErrMessage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Access Error'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Error'</span><span style="color: #339933;">,</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$SQL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDataBase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #666666; font-style: italic;">// Accesors	</span>
	<span style="color: #000000; font-weight: bold;">function</span> getQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQL</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// executes a query</span>
		<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setErrMessage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Sql Error'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Invalid query'</span><span style="color: #339933;">,</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$SQL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #666666; font-style: italic;">// create a 2D array of results</span>
		<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$row</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_fetch_assoc</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$return</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$row</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> getStateOpen<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// returns an array of details about the open connection</span>
		<span style="color: #000088;">$return</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'host'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mySqlHost</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$return</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'DB'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'database'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dataBase</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #666666; font-style: italic;">// Modifiers</span>
	<span style="color: #000000; font-weight: bold;">function</span> setDataBase<span style="color: #009900;">&#40;</span><span style="color: #000088;">$dataBaseName</span><span style="color: #339933;">=</span>NAME<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dataBase</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dataBaseName</span><span style="color: #339933;">,</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mySqlHost</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dataBase</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setErrMessage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'I/O Error'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Error'</span><span style="color: #339933;">,</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$SQL</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> setStateClose<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// closes current connection</span>
		<span style="color: #990000;">mysql_close</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$mySqlHost</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> setQuery<span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQL</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// executes a query without returning any results, used for insert, create etc, returns the ID of the last auto-increment</span>
		<span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$SQL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setErrMessage</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Sql Error'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'Invalid query'</span><span style="color: #339933;">,</span><span style="color: #990000;">mysql_error</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #000088;">$SQL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #000088;">$return</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_insert_id</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #000088;">$return</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
	<span style="color: #000000; font-weight: bold;">function</span> setErrMessage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #339933;">,</span> <span style="color: #000088;">$errName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$err</span><span style="color: #339933;">,</span> <span style="color: #000088;">$SQL</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// displays and emails, the sql error</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ERRS<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;h1 style='color=&quot;#444444;'&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$message</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h1&gt;
			&lt;hr&gt;
			&lt;p&gt;
				&lt;font color=&quot;#ff0000&quot;&gt;&lt;b&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$errName</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>: &lt;/b&gt;&lt;/font&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$err</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
				&lt;br /&gt;
				&lt;font color=&quot;#ff0000&quot;&gt;&lt;b&gt;Whole query: &lt;/b&gt;&lt;/font&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$SQL</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;/p&gt;
			&lt;hr&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span>
		<span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
			&lt;h1 style='color=&quot;#444444;&quot;'&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> MESSAGE<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h1&gt;
			&lt;hr&gt;
		<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> 
&nbsp;
		<span style="color: #666666; font-style: italic;">// email message</span>
		<span style="color: #000088;">$Name</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//senders name </span>
		<span style="color: #000088;">$email</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;noreply@&quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//senders e-mail adress </span>
&nbsp;
		<span style="color: #666666; font-style: italic;">//mail body </span>
		<span style="color: #000088;">$mail_body</span> <span style="color: #339933;">=</span> 
		<span style="color: #0000ff;">'&lt;h2&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' error&lt;/h2&gt;'</span><span style="color: #339933;">.</span>
		<span style="color: #000088;">$err</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br/&gt;'</span><span style="color: #339933;">.</span> 
		<span style="color: #0000ff;">'&lt;h2&gt;Request details&lt;/h2&gt;'</span><span style="color: #339933;">.</span>
		<span style="color: #0000ff;">'&lt;b&gt;Script filename and query string: &lt;/b&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SCRIPT_FILENAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'?'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'QUERY_STRING'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br/&gt;'</span><span style="color: #339933;">.</span>
		<span style="color: #0000ff;">'&lt;b&gt;Server name: &lt;/b&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br/&gt;'</span><span style="color: #339933;">.</span>
		<span style="color: #0000ff;">'&lt;h2&gt;User details&lt;/h2&gt;'</span><span style="color: #339933;">.</span>
		<span style="color: #0000ff;">'&lt;b&gt;IP ADDRESS: &lt;/b&gt;'</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">' : '</span><span style="color: #339933;">.</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_PORT'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br/&gt;'</span><span style="color: #339933;">.</span>
		<span style="color: #0000ff;">'&lt;b&gt;Time: &lt;/b&gt;'</span><span style="color: #339933;">.</span><span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;D dS M,Y h:i a&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;br/&gt;'</span>
		<span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$subject</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; Error&quot;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//subject </span>
&nbsp;
		<span style="color: #000088;">$header</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'MIME-Version: 1.0'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
		<span style="color: #000088;">$header</span><span style="color: #339933;">.=</span> <span style="color: #0000ff;">'Content-type: text/html; charset=iso-8859-1'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>		
		<span style="color: #000088;">$header</span><span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;From: &quot;</span><span style="color: #339933;">.</span> <span style="color: #000088;">$Name</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; &lt;&quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$email</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&gt;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> 
&nbsp;
&nbsp;
		<span style="color: #666666; font-style: italic;">// send mail, and die</span>
		<span style="color: #000088;">$sent</span> <span style="color: #339933;">=</span> <span style="color: #339933;">@</span><span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span>admin_email<span style="color: #339933;">,</span> <span style="color: #000088;">$subject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$mail_body</span><span style="color: #339933;">,</span> <span style="color: #000088;">$header</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;">$sent</span><span style="color: #009900;">&#41;</span> <span style="color: #000088;">$display</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">'&lt;h2&gt;The administrator has been notified&lt;/h2&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span> <span style="color: #000088;">$display</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">'&lt;h2&gt;Please notify the administrator '</span><span style="color: #339933;">.</span>admin_email<span style="color: #339933;">.</span><span style="color: #0000ff;">'&lt;/h2&gt;'</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000088;">$display</span><span style="color: #339933;">.=</span><span style="color: #0000ff;">'&lt;p&gt;Please call back again later&lt;/p&gt;'</span><span style="color: #339933;">;</span>
		<span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$display</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>	
	<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://adriancallaghan.co.uk/database-class-for-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
