<?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>james young &#187; php</title>
	<atom:link href="http://psyjinx.com/jyoung/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://psyjinx.com/jyoung</link>
	<description>web application developer</description>
	<lastBuildDate>Fri, 05 Mar 2010 18:55:39 +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>MediaWiki Radius Authentication Extension &#8211; RadiusAuthPlugin</title>
		<link>http://psyjinx.com/jyoung/2010/02/mediawiki-radius-authentication-extension-radiusauthplugin/</link>
		<comments>http://psyjinx.com/jyoung/2010/02/mediawiki-radius-authentication-extension-radiusauthplugin/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 02:26:52 +0000</pubDate>
		<dc:creator>James Young</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[code example]]></category>
		<category><![CDATA[mediawiki]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[radius]]></category>
		<category><![CDATA[wiki]]></category>

		<guid isPermaLink="false">http://psyjinx.com/jyoung/?p=244</guid>
		<description><![CDATA[<p>Here is an extension / plugin for mediawiki to authenticate against a Radius server.  I couldn&#8217;t find one anywhere else, which is surprising.  I can&#8217;t believe I am the first person to want to do this.  Anyway, this is just bare bones, but it works for an internal mediawiki setup.</p>
<p>First, get Pure [...]]]></description>
			<content:encoded><![CDATA[<p>Here is an extension / plugin for mediawiki to authenticate against a Radius server.  I couldn&#8217;t find one anywhere else, which is surprising.  I can&#8217;t believe I am the first person to want to do this.  Anyway, this is just bare bones, but it works for an internal mediawiki setup.</p>
<p>First, get Pure PHP radius class 1.2.2 from <a href="http://developer.sysco.ch/php">http://developer.sysco.ch/php</a>.  This does the actual radius authentication.  Put radius.class.php in wiki/extensions/ (assuming wiki is your mediawiki install).  There is probably a better place to put it, but I was setting this up for internal use and wanted to get it working quickly.</p>
<p>Next, create wiki/extensions/RadiusAuthPlugin.php.  Make sure you fill in RADIUS_SERVER, SHARED_SECRET, and NAS_IP_ADDRESS with your actual information</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'AuthPlugin.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'radius.class.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">error_reporting</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">E_ALL</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> RadiusAuthPlugin <span style="color: #000000; font-weight: bold;">extends</span> AuthPlugin
<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">function</span> userExists<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> authenticate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$username</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$radius</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Radius<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'RADIUS_SERVER'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'SHARED_SECRET'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$radius</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">SetNasIpAddress</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'NAS_IP_ADDRESS'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Needed for some devices (not always auto-detected)</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$radius</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">AccessRequest</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$username</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> modifyUITemplate<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$template</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'usedomain'</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: #000088;">$template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'useemail'</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: #000088;">$template</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'create'</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: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> autoCreate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> validDomain<span style="color: #009900;">&#40;</span><span style="color: #000088;">$domain</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> updateUser<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> allowPasswordChange<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> setPassword<span style="color: #009900;">&#40;</span><span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> updateExternalDB<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> canCreateAccounts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> adduser<span style="color: #009900;">&#40;</span><span style="color: #000088;">$user</span><span style="color: #339933;">,</span> <span style="color: #000088;">$password</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> strict<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">TRUE</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
    <span style="color: #000000; font-weight: bold;">function</span> initUser<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$user</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #000088;">$wgExtensionCredits</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'other'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'name'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'RadiusAuthPlugin'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'version'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'1.0.0'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'author'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'James Young'</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'description'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Automatic login with a RADIUS server'</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Lastly, put this in your LocalSetup.php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;./extensions/RadiusAuthPlugin.php&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wgAuth</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RadiusAuthPlugin<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wgGroupPermissions</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'*'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'createaccount'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://psyjinx.com/jyoung/2010/02/mediawiki-radius-authentication-extension-radiusauthplugin/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Obscure PHP5 information</title>
		<link>http://psyjinx.com/jyoung/2009/11/obscure-php5-information/</link>
		<comments>http://psyjinx.com/jyoung/2009/11/obscure-php5-information/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 16:29:54 +0000</pubDate>
		<dc:creator>James Young</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://psyjinx.com/jyoung/?p=191</guid>
		<description><![CDATA[
&#60;?= $variable ?&#62; is depreciated in PHP5 (along w/ all other tags that are not &#60;?php ?&#62;).  I don&#8217;t care so much about the others, but I actually use this one.  &#60;?= $title ?&#62; just makes more sense than &#60;?php echo $title; ?&#62;
The last instruction before a closing tag does not require a semicolon; however, [...]]]></description>
			<content:encoded><![CDATA[<ul>
<li><code>&lt;?= $variable ?&gt;</code> is depreciated in PHP5 (along w/ all other tags that are not <code>&lt;?php ?&gt;</code>).  I don&#8217;t care so much about the others, but I actually use this one.  <code>&lt;?= $title ?&gt;</code> just makes more sense than <code>&lt;?php echo $title; ?&gt;</code></li>
<li>The last instruction before a closing tag does not require a semicolon; however, this is probably a bug in the PHP parser and you should always terminate it anyway. Perhaps <code>&lt;?= $variable ?&gt;</code> should actually be <code>&lt;?= $variable; ?&gt;</code>.</li>
<li>use BCMath functions for precision math.  This isn&#8217;t really obscure, but every now and then I run into people that have never heard of it, so it makes the list.</li>
<li>Referring to a variable by-reference is slower than referring to a variable by-value (<code>&amp;$a</code> vs. <code>$a</code>)</li>
<li>more to come&#8230;.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://psyjinx.com/jyoung/2009/11/obscure-php5-information/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>YUI DataTable &#8211; Using a dateCellEditor with an asyncSubmitter</title>
		<link>http://psyjinx.com/jyoung/2009/07/yui-datatable-using-a-datecelleditor-with-an-asyncsubmitter/</link>
		<comments>http://psyjinx.com/jyoung/2009/07/yui-datatable-using-a-datecelleditor-with-an-asyncsubmitter/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 03:02:26 +0000</pubDate>
		<dc:creator>James Young</dc:creator>
				<category><![CDATA[yui]]></category>
		<category><![CDATA[asyncSubmitter]]></category>
		<category><![CDATA[code example]]></category>
		<category><![CDATA[datatable]]></category>
		<category><![CDATA[dateCellEditor]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://psyjinx.com/wp/?p=86</guid>
		<description><![CDATA[<p>If you are wondering what a dateCellEditor and asyncSubmitter are go check out http://developer.yahoo.com/yui/examples/datatable/dt_cellediting.html.  See the last_login column?  Click on that, you will get a cool calendar that pops up for you to change the date.  Pretty handy. That Inline Cell Editing page touches on how to implement that, but it doesn&#8217;t cover the actual [...]]]></description>
			<content:encoded><![CDATA[<p>If you are wondering what a dateCellEditor and asyncSubmitter are go check out http://developer.yahoo.com/yui/examples/datatable/dt_cellediting.html.  See the last_login column?  Click on that, you will get a cool calendar that pops up for you to change the date.  Pretty handy. That <a href="http://developer.yahoo.com/yui/examples/datatable/dt_cellediting.html">Inline Cell Editing</a> page touches on how to implement that, but it doesn&#8217;t cover the actual asyncSubmitter when using a dateCellEditor which is where I could have used a bit more information.  </p>
<p>This example uses five files:</p>
<ul>
<li>index.html &#8211; template for the page</li>
<li>javascript.js &#8211; javascript that powers the datatable</li>
<li>datatabledata.php &#8211; back end process that returns the data for the datatable in JSON format</li>
<li>update.php &#8211; back end process that updates the data in the database based on what the user changed</li>
</ul>
<p>Below is a code example that spells it all out.</p>
<p><span id="more-86"></span><br />
<em>index.html</em></p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #00bbdd;">&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01//EN&quot; &quot;http://www.w3.org/TR/html4/strict.dtd&quot;&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">html</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">title</span>&gt;</span>DataTable inline cell editing with dateCellEditor and asyncSubmitter example<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">title</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.7.0/build/base/base-min.css&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.7.0/build/datatable/assets/skins/sam/datatable.css&quot;</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.7.0/build/calendar/assets/skins/sam/calendar.css&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">head</span>&gt;</span>
&nbsp;
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">body</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">'yui-skin-sam'</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">id</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;datatable&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.7.0/build/yahoo-dom-event/yahoo-dom-event.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.7.0/build/connection/connection-min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.7.0/build/calendar/calendar-min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.7.0/build/json/json-min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.7.0/build/element/element-min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.7.0/build/datasource/datasource-min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://yui.yahooapis.com/2.7.0/build/datatable/datatable-min.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
    <span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;javascript.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">script</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">body</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">html</span>&gt;</span></pre></div></div>

<p><em>javascript.js</em></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> STWPT <span style="color: #339933;">=</span> YAHOO.<span style="color: #003366; font-weight: bold;">namespace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;stwpt&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
STWPT.<span style="color: #660066;">init</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    STWPT.<span style="color: #660066;">getDataTableData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
STWPT.<span style="color: #660066;">getDataTableData</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> submitter <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>callback<span style="color: #339933;">,</span> newValue<span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> record <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getRecord</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> column <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getColumn</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> oldValue <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
        <span style="color: #003366; font-weight: bold;">var</span> datatable <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getDataTable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #006600; font-style: italic;">// send the data to our update page to update the value in the database</span>
        YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Connect</span>.<span style="color: #660066;">asyncRequest</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'POST'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'update.php'</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#123;</span>
            success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>o<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #003366; font-weight: bold;">var</span> r <span style="color: #339933;">=</span> YAHOO.<span style="color: #660066;">lang</span>.<span style="color: #660066;">JSON</span>.<span style="color: #660066;">parse</span><span style="color: #009900;">&#40;</span>o.<span style="color: #660066;">responseText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>r.<span style="color: #660066;">replyType</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'date'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> r.<span style="color: #660066;">data</span> <span style="color: #339933;">=</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">DataSource</span>.<span style="color: #660066;">parseDate</span><span style="color: #009900;">&#40;</span>r.<span style="color: #660066;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>r.<span style="color: #660066;">replyCode</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'201'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> callback<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> r.<span style="color: #660066;">data</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
                <span style="color: #000066; font-weight: bold;">else</span>
                <span style="color: #009900;">&#123;</span>
                    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>r.<span style="color: #660066;">replyText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    callback<span style="color: #009900;">&#40;</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: #339933;">,</span>
            failure<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>o<span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>o.<span style="color: #660066;">statusText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                callback<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            scope<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'action=cellEdit&amp;column='</span> <span style="color: #339933;">+</span> column.<span style="color: #660066;">key</span> <span style="color: #339933;">+</span>
                     <span style="color: #3366CC;">'&amp;newValue='</span> <span style="color: #339933;">+</span> escape<span style="color: #009900;">&#40;</span>newValue<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>
                     <span style="color: #3366CC;">'&amp;oldValue='</span> <span style="color: #339933;">+</span> escape<span style="color: #009900;">&#40;</span>oldValue<span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>
                      <span style="color: #3366CC;">'&amp;team_id='</span> <span style="color: #339933;">+</span> record.<span style="color: #660066;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'team_id'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span>
                     <span style="color: #3366CC;">'&amp;type=team'</span>
        <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> textEditor <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #660066;">widget</span>.<span style="color: #660066;">TextboxCellEditor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> disableBtns<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> asyncSubmitter<span style="color: #339933;">:</span> submitter <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> myColumnDefs <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
        <span style="color: #009900;">&#123;</span> key<span style="color: #339933;">:</span> <span style="color: #3366CC;">'team_id'</span><span style="color: #339933;">,</span> label<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Id'</span><span style="color: #339933;">,</span> hidden<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#123;</span> key<span style="color: #339933;">:</span> <span style="color: #3366CC;">'name'</span><span style="color: #339933;">,</span> label<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Team Name'</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> resizeable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> editor<span style="color: #339933;">:</span> textEditor <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#123;</span> key<span style="color: #339933;">:</span> <span style="color: #3366CC;">'start_date'</span><span style="color: #339933;">,</span> label<span style="color: #339933;">:</span> <span style="color: #3366CC;">'Start Date'</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> resizeable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> editor<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #660066;">widget</span>.<span style="color: #660066;">DateCellEditor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> asyncSubmitter<span style="color: #339933;">:</span> submitter <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> formatter<span style="color: #339933;">:</span> YAHOO.<span style="color: #660066;">widget</span>.<span style="color: #660066;">DataTable</span>.<span style="color: #660066;">formatDate</span>
        <span style="color: #009900;">&#123;</span> key<span style="color: #339933;">:</span> <span style="color: #3366CC;">'end_date'</span><span style="color: #339933;">,</span> label<span style="color: #339933;">:</span> <span style="color: #3366CC;">'End Date'</span><span style="color: #339933;">,</span> sortable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> resizeable<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span> editor<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #660066;">widget</span>.<span style="color: #660066;">DateCellEditor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> asyncSubmitter<span style="color: #339933;">:</span> submitter <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> formatter<span style="color: #339933;">:</span> YAHOO.<span style="color: #660066;">widget</span>.<span style="color: #660066;">DataTable</span>.<span style="color: #660066;">formatDate</span> <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> myDataSource <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">DataSource</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'datatabledata.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    myDataSource.<span style="color: #660066;">responseType</span> <span style="color: #339933;">=</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">DataSource</span>.<span style="color: #660066;">TYPE_JSON</span><span style="color: #339933;">;</span>
    myDataSource.<span style="color: #660066;">connXhrMode</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'queueRequests'</span><span style="color: #339933;">;</span>
    myDataSource.<span style="color: #660066;">connMethodPost</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
    myDataSource.<span style="color: #660066;">responseSchema</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        resultsList<span style="color: #339933;">:</span> <span style="color: #3366CC;">'teams'</span><span style="color: #339933;">,</span>
        fields<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'team_id'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'name'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> key<span style="color: #339933;">:</span> <span style="color: #3366CC;">'start_date'</span><span style="color: #339933;">,</span> parser<span style="color: #339933;">:</span> <span style="color: #3366CC;">'date'</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span> key<span style="color: #339933;">:</span> <span style="color: #3366CC;">'end_date'</span><span style="color: #339933;">,</span> parser<span style="color: #339933;">:</span> <span style="color: #3366CC;">'date'</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#93;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> myDataTable <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #660066;">widget</span>.<span style="color: #660066;">DataTable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'datatable'</span><span style="color: #339933;">,</span> myColumnDefs<span style="color: #339933;">,</span> myDataSource<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> onCellClick <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>oArgs<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onEventShowCellEditor</span><span style="color: #009900;">&#40;</span>oArgs<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    myDataTable.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'cellClickEvent'</span><span style="color: #339933;">,</span> onCellClick<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> mySuccessHandler <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
       <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">onDataReturnAppendRows</span>.<span style="color: #660066;">apply</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> arguments<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> myFailureHandler <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'FAIL'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #003366; font-weight: bold;">var</span> callback <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
        success<span style="color: #339933;">:</span> mySuccessHandler<span style="color: #339933;">,</span>
        failure<span style="color: #339933;">:</span> myFailureHandler<span style="color: #339933;">,</span>
        scope<span style="color: #339933;">:</span> myDataTable
    <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">onDOMReady</span><span style="color: #009900;">&#40;</span>STWPT.<span style="color: #660066;">init</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><em>datatabledata.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// NOTE: if this wasn't an example, this would be done in CodeIgniter</span>
<span style="color: #990000;">mysql_pconnect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'msyql_username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mysql_password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql_database_name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$user_id</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">// hardcoded for this example</span>
<span style="color: #000088;">$facility_id</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// hardcoded for this example</span>
&nbsp;
<span style="color: #000088;">$teams</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>
&nbsp;
<span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;SELECT t.id AS team_id,
               t.name,
               t.datatable_key,
               DATE_FORMAT(t.start_date, '%m/<span style="color: #009933; font-weight: bold;">%d</span>/%Y') AS start_date,
               DATE_FORMAT(t.end_date, '%m/<span style="color: #009933; font-weight: bold;">%d</span>/%Y') AS end_date
          FROM teams AS t,
               user_facility_teams AS uft
         WHERE uft.user_id = <span style="color: #006699; font-weight: bold;">{$user_id}</span>
           AND uft.facility_id = <span style="color: #006699; font-weight: bold;">{$facility_id}</span>
           AND t.id = uft.team_id
&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$result</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>
&nbsp;
<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_array</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: #009900;">&#123;</span>
    <span style="color: #990000;">array_push</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$teams</span><span style="color: #339933;">,</span> <span style="color: #000088;">$row</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'{&quot;teams&quot; : '</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</span> <span style="color: #339933;">.=</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$teams</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$response</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;">$response</span><span style="color: #339933;">;</span></pre></div></div>

<p><em>update.php</em></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">// NOTE: if this wasn't an example, this would be done in CodeIgniter</span>
<span style="color: #990000;">mysql_pconnect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'msyql_username'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'mysql_password'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql_database_name'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$user_id</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>      <span style="color: #666666; font-style: italic;">// hardcoded for this example</span>
<span style="color: #000088;">$facility_id</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// hardcoded for this example</span>
&nbsp;
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'column'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'column'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'newValue'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'team_id'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'team_id'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
<span style="color: #000088;">$json_response_value</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #990000;">mysql_real_escape_string</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$key</span><span style="color: #009900;">&#93;</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;">// if we are changing the 'name' we must also update the key used for datatable column definitions</span>
<span style="color: #000088;">$set_datatable_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'column'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$datatable_key</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/[ -]/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'_'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$datatable_key</span> <span style="color: #339933;">=</span> <span style="color: #990000;">preg_replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'/%/'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'percent'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$datatable_key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$datatable_key</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$datatable_key</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$set_datatable_key</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;, datatable_key = '<span style="color: #006699; font-weight: bold;">{$datatable_key}</span>'&quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;UPDATE teams
               SET <span style="color: #006699; font-weight: bold;">{$data['column']}</span> = '<span style="color: #006699; font-weight: bold;">{$data['value']}</span>' <span style="color: #006699; font-weight: bold;">{$set_datatable_key}</span>
             WHERE id = <span style="color: #006699; font-weight: bold;">{$data['team_id']}</span>
    &quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$replyType</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'string'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'column'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'start_date'</span> <span style="color: #339933;">||</span> <span style="color: #000088;">$data</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'column'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'end_date'</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$sql</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;UPDATE teams
               SET <span style="color: #006699; font-weight: bold;">{$data['column']}</span> = STR_TO_DATE('<span style="color: #006699; font-weight: bold;">{$data['value']}</span>', '%a <span style="color: #009933; font-weight: bold;">%b</span> <span style="color: #009933; font-weight: bold;">%d</span> %Y')
             WHERE id = <span style="color: #006699; font-weight: bold;">{$data['team_id']}</span>
    &quot;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$replyType</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'date'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$result</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>
&nbsp;
<span style="color: #000088;">$response</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'replyCode'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'201'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'replyText'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'Ok'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'replyType'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$replyType</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'data'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$json_response_value</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #990000;">json_encode</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$response</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://psyjinx.com/jyoung/2009/07/yui-datatable-using-a-datecelleditor-with-an-asyncsubmitter/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to setup a Mac OS X MAMP based Web Server</title>
		<link>http://psyjinx.com/jyoung/2009/01/how-to-setup-a-mac-os-x-mamp-based-web-server/</link>
		<comments>http://psyjinx.com/jyoung/2009/01/how-to-setup-a-mac-os-x-mamp-based-web-server/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 20:32:53 +0000</pubDate>
		<dc:creator>James Young</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[cronolog]]></category>
		<category><![CDATA[dbd]]></category>
		<category><![CDATA[dbi]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[mamp]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phpmyadmin]]></category>

		<guid isPermaLink="false">http://psyjinx.com/wp/?p=33</guid>
		<description><![CDATA[

In the past I had a mediawiki setup on my local MBP that I would use to keep notes.  This is a copy/paste of this article.  The ToC links do not work, but the rest of the links should work.   If you need to setup MAMP on a Mac, keep on reading after the break.</p>






Contents
<p>(these [...]]]></description>
			<content:encoded><![CDATA[<div id="globalWrapper">
<div id="column-content">
<div id="content">In the past I had a mediawiki setup on my local MBP that I would use to keep notes.  This is a copy/paste of this article.  The ToC links do not work, but the rest of the links should work.   If you need to setup MAMP on a Mac, keep on reading after the break.</p>
<div id="bodyContent">
<table id="toc" border="0" summary="Contents">
<tbody>
<tr>
<td>
<div id="toctitle">
<h2>Contents</h2>
<p>(these links don&#8217;t work in wordpress)
</p></div>
<ul>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Download_Required_Software"><span>1</span> <span>Download Required Software</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Base_Setup"><span>2</span> <span>Base Setup</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Configure_Mac_OS_X"><span>3</span> <span>Configure Mac OS X</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Install_MAMP"><span>4</span> <span>Install MAMP</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Configure_MAMP_and_Apache"><span>5</span> <span>Configure MAMP and Apache</span></a>
<ul>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#The_MAMP_Application"><span>5.1</span> <span>The MAMP Application</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Mac_OS_X_Settings"><span>5.2</span> <span>Mac OS X Settings</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Symlinks_and_New_Directories"><span>5.3</span> <span>Symlinks and New Directories</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Apache_httpd.conf"><span>5.4</span> <span>Apache httpd.conf</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Create_htpasswd_file_for_Authentication"><span>5.5</span> <span>Create htpasswd file for Authentication</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#vhost_.conf_file"><span>5.6</span> <span>vhost .conf file</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#.profile_or_.bash_profile_or_.bashrc"><span>5.7</span> <span>.profile or .bash_profile or .bashrc</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Configure_MAMP_to_Start_Silently_on_Boot"><span>5.8</span> <span>Configure MAMP to Start Silently on Boot</span></a>
<ul>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#info.mamp.start.apache.plist"><span>5.8.1</span> <span>info.mamp.start.apache.plist</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#info.mamp.start.mysql.plist"><span>5.8.2</span> <span>info.mamp.start.mysql.plist</span></a></li>
</ul>
</li>
</ul>
</li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Install_Cronolog"><span>6</span> <span>Install Cronolog</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Confirming_It_Works"><span>7</span> <span>Confirming It Works</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Configure_PHPMyAdmin"><span>8</span> <span>Configure PHPMyAdmin</span></a>
<ul>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Consequences_of_Changing_the_root_Password_.28which_you_should_do.29"><span>8.1</span> <span>Consequences of Changing the root Password (which you should do)</span></a></li>
</ul>
</li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Install_DBI_and_DBD::MySQL"><span>9</span> <span>Install DBI and DBD::MySQL</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Install_PERL_CGI"><span>10</span> <span>Install PERL CGI</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Available_Tools"><span>11</span> <span>Available Tools</span></a></li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#FAQ"><span>12</span> <span>FAQ</span></a>
<ul>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#Why_do_you_do_all_these_settings_and_not_just_use_the_defaults_setup_by_MAMP"><span>12.1</span> <span>Why do you do all these settings and not just use the defaults setup by MAMP</span></a></li>
</ul>
</li>
<li><a href="../../wiki/index.php?title=Setup_a_Mac_OS_X_MAMP_Based_Web_Server&amp;printable=yes#References"><span>13</span> <span>References</span></a></li>
</ul>
</td>
</tr>
</tbody>
</table>
<p><script type="text/javascript">// <![CDATA[
    if (window.showTocToggle) { var tocShowText = "show"; var tocHideText = "hide"; showTocToggle(); }
// ]]&gt;</script></p>
<p><span id="more-33"></span></p>
<h2><span>Download Required Software </span></h2>
<ul>
<li> MAMP &#8211; <a title="http://download.living-e.com/MAMP/releases/1.7.2/MAMP_1.7.2.dmg" rel="nofollow" href="http://download.living-e.com/MAMP/releases/1.7.2/MAMP_1.7.2.dmg">http://download.living-e.com/MAMP/releases/1.7.2/MAMP_1.7.2.dmg</a></li>
<li> cronolog &#8211; <a title="http://cronolog.org/download/cronolog-1.6.2.tar.gz" rel="nofollow" href="http://cronolog.org/download/cronolog-1.6.2.tar.gz">http://cronolog.org/download/cronolog-1.6.2.tar.gz</a></li>
</ul>
<h2><span>Base Setup </span></h2>
<p>This article assumes you have a clean Mac OS X 10.5.x install on a mac and have installed the XCode Developer Tools.</p>
<h2><span>Configure Mac OS X </span></h2>
<p>There are a variety of things I do when I configure a new Mac. Most of it is personal preferences, some of it is for performance (like setting a solid color desktop background on a machine I know I will only see via Screen Sharing), other things for configuring a work environment. All of that is out of scope for what we are doing here, so just do the following as a the minimum. I will create a page for configuring a Mac dev box in the future that will go into all the details of how I configure my system, .profile, .vimrc, .screenrc, etc.</p>
<ul>
<li> Open Software Update and make sure that you are up to date on everything.</li>
<li> Open System Preferences -&gt; Sharing and make sure that the following are on and everything else is off
<ul>
<li> Screen Sharing</li>
<li> File Sharing &#8211; Click Options and make sure &#8216;Share files and folders using FTP&#8217; is checked</li>
<li> Remote Login</li>
</ul>
</li>
<li> Make sure the Computer Name is one word without spaces or apostrophes. Something like kimiko is good, something like Jamie&#8217;s MacBook Pro is bad</li>
</ul>
<h2><span> Install MAMP </span></h2>
<p>MAMP is a .dmg so if you have direct control on the machine or remote access that is ideal. Download the .dmg, mount it, drag MAMP to the Applications folder and you are done with the install.</p>
<h2><span> </span><span>Configure MAMP and Apache </span></h2>
<p>These steps are too interlaced to separate configuring MAMP and configuring Apache into separate sections.</p>
<h3><span>The MAMP Application </span></h3>
<ul>
<li> Launch up MAMP. The first time it launches it will start up your default web browser (probably Safari if you haven&#8217;t already installed Firefox) and turn everything on.</li>
<li> Click the Stop Servers button to stop everything</li>
<li> Click the Preferences and do the following:
<ul>
<li> on Start/Stop, uncheck everything</li>
<li> on Ports, Set to default Apache and MySQL ports</li>
<li> on PHP, use PHP5, uncheck Zend Optimizer, and use APC for the Cache</li>
<li> on Apache, set the document root to /Library/WebServer/Documents</li>
</ul>
</li>
<li> Quit the MAMP application</li>
</ul>
<h3><span>Mac OS X Settings </span></h3>
<ul>
<li> In Finder, open <code>/Applications/MAMP/</code> and delete all the readme files that are in a language that you can&#8217;t read and delete the htdocs folder</li>
</ul>
<h3><span>Symlinks and New Directories </span></h3>
<p>In Terminal, go to your MAMP directory, create a symlink named <code>htdocs</code> to <code>/Library/WebServer/Documents/</code>, go to <code>/etc</code> and create a symlink for <code>mamp</code> to <code>/Applications/MAMP/conf</code>, move apache2 to apache2.d (I don&#8217;t like deleting things), create a symlink for apache2 to <code>/Applications/MAMP/conf/apache</code>,  go to <code>/etc/mamp/apache</code> and create a <code>vhosts</code> folder, and go to <code>/var/log</code> and create a symlink for <code>mamp</code> to <code>/Applications/MAMP/logs</code>.  If you aren&#8217;t positive how to do all that, here is a transcript:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP
$ <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>WebServer<span style="color: #000000; font-weight: bold;">/</span>Documents htdocs
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>conf mamp
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> apache2 apache2.d
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>conf<span style="color: #000000; font-weight: bold;">/</span>apache apache2
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>mamp<span style="color: #000000; font-weight: bold;">/</span>apache
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> vhosts
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>logs mamp</pre></div></div>

<h3><span>Apache httpd.conf </span></h3>
<p>There are some changes you will want to make to the httpd.conf file. <code>$ sudo vim /etc/mamp/apache/httpd.conf</code>. All line numbers referenced below are from MAMP 1.7.2 and the higher the number gets, the more chance they are of being wrong cause I didn&#8217;t really pay attention to what all I edited that added lines as I went.</p>
<ul>
<li> Turn on ExtendedStatus (for non-production servers only).  This is on line 295.  Change <code>#ExtendedStatus On</code> to <code>ExtendedStatus On</code> (remove the hash (#))</li>
<li> Make sure User on line 326 has administrative privileges on the mac.</li>
<li> ServerAdmin on line 336 should an email address that you can be contacted at (this is not all that important to change if you are going to setup vhosts)</li>
<li> ServerName on line 351 should be the domain name you are using (this is also not all that important if you are going to setup vhosts)</li>
<li> IMPORTANT, on line 639 you will notice that /Applications/MAMP/bin/SQLiteManger and /Applications/MAMP/bin/mamp are shared and publically available. While convenient for administrators, this is not good for the public to see, so you will want to set a password on these directories. We will insure that phpmyadmin asks for a password later as well. Change that section to look like this:</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">Alias</span> /SQLiteManager <span style="color: #7f007f;">&quot;/Applications/MAMP/bin/SQLiteManager&quot;</span>
&nbsp;
&lt;<span style="color: #000000; font-weight:bold;">Directory</span> <span style="color: #7f007f;">&quot;/Applications/MAMP/bin/SQLiteManager&quot;</span>&gt;
    <span style="color: #00007f;">Options</span> <span style="color: #0000ff;">Indexes</span> MultiViews
    <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">None</span>
    <span style="color: #00007f;">AuthType</span> Basic
    <span style="color: #00007f;">AuthName</span> <span style="color: #7f007f;">&quot;YOUR_SERVER_HOSTNAME&quot;</span>
    <span style="color: #00007f;">AuthUserFile</span> /Library/WebServer/passwords/password
    <span style="color: #00007f;">Require</span> valid-<span style="color: #00007f;">user</span>
&lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
&nbsp;
<span style="color: #00007f;">Alias</span> /MAMP <span style="color: #7f007f;">&quot;/Applications/MAMP/bin/mamp&quot;</span>
&nbsp;
&lt;<span style="color: #000000; font-weight:bold;">Directory</span> <span style="color: #7f007f;">&quot;/Applications/MAMP/bin/mamp&quot;</span>&gt;
    <span style="color: #00007f;">Options</span> <span style="color: #0000ff;">Indexes</span> MultiViews
    <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">None</span>
    <span style="color: #00007f;">AuthType</span> Basic
    <span style="color: #00007f;">AuthName</span> <span style="color: #7f007f;">&quot;YOUR_SERVER_HOSTNAME&quot;</span>
    <span style="color: #00007f;">AuthUserFile</span> /Library/WebServer/passwords/password
    <span style="color: #00007f;">Require</span> valid-<span style="color: #00007f;">user</span>
&lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;</pre></div></div>

<ul>
<li> Uncomment relevant lines 1087 &#8211; 1092, this will turn on server-status (only do this on non-production boxes).  Either leave <code>Allow from .example.com</code> commented out and add <code>Allow from all</code> or put in a valid domain name in place of .example.com</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">Location</span> /server-status&gt;
    <span style="color: #00007f;">SetHandler</span> server-status
    <span style="color: #00007f;">Order</span> <span style="color: #00007f;">deny</span>,<span style="color: #00007f;">allow</span>
    <span style="color: #00007f;">Deny</span> <span style="color: #00007f;">from</span> <span style="color: #00007f;">all</span>
    <span style="color: #00007f;">Allow</span> <span style="color: #00007f;">from</span> <span style="color: #00007f;">all</span>
&lt;/<span style="color: #000000; font-weight:bold;">Location</span>&gt;</pre></div></div>

<ul>
<li> Uncomment line 1133 for the <code>NameVirtualHost</code> and add lines so it looks like this:</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;"><span style="color: #00007f;">NameVirtualHost</span> *:<span style="color: #ff0000;">80</span>
&nbsp;
&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">DocumentRoot</span> /Library/WebServer/Documents/
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;
&nbsp;
<span style="color: #00007f;">Include</span> /Applications/MAMP/conf/apache/vhosts/*.conf</pre></div></div>

<h3><span>Create htpasswd file for Authentication </span></h3>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>WebServer<span style="color: #000000; font-weight: bold;">/</span>passwords
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>WebServer<span style="color: #000000; font-weight: bold;">/</span>passwords
$ htpasswd <span style="color: #660033;">-cs</span> password username</pre></div></div>

<h3><span> vhost .conf file </span></h3>
<p>A typical vhost file should be in /etc/mamp/apache/vhosts and look something like the following. Don&#8217;t worry about the cronolog line yet, we will install that later down in this article.</p>

<div class="wp_syntax"><div class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
    <span style="color: #00007f;">ServerName</span> psyjinx.com
    <span style="color: #00007f;">ServerAdmin</span> jyoung@psyjinx.com
    <span style="color: #00007f;">ServerAlias</span> *.psyjinx.com
    <span style="color: #00007f;">DocumentRoot</span> /Library/WebServer/Documents/psyjinx/
    <span style="color: #00007f;">ErrorLog</span> <span style="color: #7f007f;">&quot;|/usr/sbin/cronolog /var/log/mamp/psyjinx_error_log-%Y%m%d&quot;</span>
    <span style="color: #00007f;">CustomLog</span> <span style="color: #7f007f;">&quot;|/usr/sbin/cronolog /var/log/mamp/psyjinx_access_log-%Y%m%d&quot;</span> combined
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></div></div>

<h3><span> </span><span> .profile or .bash_profile or .bashrc </span></h3>
<p>You will need to make the following changes to your .bash_profile or .profile (or .bashrc). I recommend just using a .profile. Again, there will be a different article on all the changes I typically put in my .profile. At a minimum you should add the following:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #007800;">$PATH</span></pre></div></div>

<h3><span> </span><span> Configure MAMP to Start Silently on Boot </span></h3>
<p>MAMP by default only starts the servers when you boot the computer, sign in as a user, and launch the application. This is not acceptable if your server is being used for anything other than personal use. Ideally you want MAMP to start on boot, so when the power goes out in the middle of the night and comes back on, the computer will boot up automatically and everything will just work without you needing to drive to the office, login in and launch an application.</p>
<p>This involves created 2 files and placing them in /Library/LaunchDaemons/. You need to have root privledges to do this, so you must use the terminal. I use vim.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchDaemons<span style="color: #000000; font-weight: bold;">/</span>info.mamp.start.apache.plist
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">touch</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchDaemons<span style="color: #000000; font-weight: bold;">/</span>info.mamp.start.mysql.plist</pre></div></div>

<p><strong>UPDATE:</strong> At some point in the 10.5.x life this changed.  I haven&#8217;t narrowed it down to what update breaks this, but something does.  If you have the most current 10.5.x, you will want to put the apache startup file in LaunchDaemons and you will want to put the mysql startup file in LaunchAgents and chown it to admin and NOT chown the db and tmp directories.</p>
<p>The two files should look like this:</p>
<h4><span> </span> <span>info.mamp.start.apache.plist </span></h4>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE plist PUBLIC &quot;-//Apple/DTD PLIST 1.0//EN&quot; &quot;http://www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plist</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Label<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>info.mamp.start.apache<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ProgramArguments<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/Applications/MAMP/Library/bin/apachectl<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>start<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>RunAtLoad<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;true</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plist<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h4><span> </span><span> info.mamp.start.mysql.plist </span></h4>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;UTF-8&quot;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #00bbdd;">&lt;!DOCTYPE plist PUBLIC &quot;-//Apple Computer//DTD PLIST 1.0//EN&quot; &quot;http:// www.apple.com/DTDs/PropertyList-1.0.dtd&quot;&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;plist</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Label<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>info.mamp.start.mysql<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>ProgramArguments<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>/Applications/MAMP/Library/bin/mysqld_safe<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>--port=3306<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>--socket=/Applications/MAMP/tmp/mysql/mysql.sock<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>--lower_case_table_names=0<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>--pid-file=/Applications/MAMP/tmp/mysql/mysql.pid<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>--log-error=/Applications/MAMP/logs/mysql_error_log<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/string<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/array<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>RunAtLoad<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/key<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;true</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dict<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/plist<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Before this can do it&#8217;s magic you need to change some permissions for mysql.<br />
NOTE: I have noticed some inconsistent results with this.  Try everything without changing permissions first.  If something doesn&#8217;t work, give the following a shot.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> mysql:admin <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>db<span style="color: #000000; font-weight: bold;">/</span>mysql
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> mysql:admin <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>mysql</pre></div></div>

<h2><span> </span><span>Install Cronolog </span></h2>
<p>Cronolog is what I last used to do log rotation. I can&#8217;t say it works exactly the way I want it to, or more likely I haven&#8217;t configured it correctly. Once you download it, un tar.gz it, compile it and move it to the proper place.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> to<span style="color: #000000; font-weight: bold;">/</span>whereever<span style="color: #000000; font-weight: bold;">/</span>you<span style="color: #000000; font-weight: bold;">/</span>saved<span style="color: #000000; font-weight: bold;">/</span>cronolog-1.6.2.tar.gz
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvzf</span> cronolog-1.6.2.tar.gz
$ <span style="color: #7a0874; font-weight: bold;">cd</span> cronolog-1.6.2
$ .<span style="color: #000000; font-weight: bold;">/</span>configure
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> src<span style="color: #000000; font-weight: bold;">/</span>cronolog <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<h2><span> </span><span> Confirming It Works </span></h2>
<p>Ok, you should be done. Restart your computer and on boot Apache and MySQL should startup on boot. You can confirm this by trying to hit your machine from a different machine on your network with a web browser or log in and start up the MAMP application and make sure it shows Apache and MySQL as running.</p>
<h2><span> </span><span> Configure PHPMyAdmin </span></h2>
<p>There isn&#8217;t much to do here, but you want to make sure it asks for a password, so you want to edit the <code>config.inc.php</code> file in <code>/Applications/MAMP/bin/phpMyAdmin</code> and make sure <code>$cfg['Servers'][$i]['auth_type']</code> is set to <code>http</code>.  It is on line 84 (or thereabouts) and should look like this when you are done:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$cfg</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'Servers'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'auth_type'</span><span style="color: #009900;">&#93;</span>     <span style="color: #339933;">=</span> <span style="color: #0000ff;">'http'</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Authentication method (config, http or cookie based)?</span></pre></div></div>

<p>Go to <a title="http://localhost/phpMyAdmin" rel="nofollow" href="http://localhost/phpMyAdmin">http://localhost/phpMyAdmin</a> to make sure it is working.  The default user/pass for MAMP is <code>root</code> / <code>root</code>.  You will want to change this.  In phpmyadmin, click on <code>Privileges</code>. You should see a page w/ 3 users listed. Only one of which will have Grant privilegs, the User should be root. In the last column on that row, click the edit icon, scroll down to the &#8216;Change Password&#8217; section and change the password to something you will never forget.</p>
<h3><span> Consequences of Changing the root Password (which you should do) </span></h3>
<ul>
<li> <code>/Applications/MAMP/bin/stopMysql.sh</code> will need to be updated.  Just edit it with vim (or something), change -proot to -p[yournewpassword]</li>
<li><code>/Applications/MAMP/bin/mamp/index.php</code> will need to be updated.  At a minimum you need to change the <code>$link</code>, otherwise this page will only show a mysql error when loaded.  change the 2nd &#8216;root&#8217; to be your new password.</li>
</ul>
<h2> <span>Install DBI and DBD::MySQL</span></h2>
<p>It is unfortunate that this does not work out of the box, cause it was a pain to figure out. The MAMP pre-compiled .dmg does not have the mysql include and lib folders with it. You need to get the MAMP source, configure and build mysql from there, then move the include and lib folders in place. Unfortunately the lib folder has synlinks pointing all over the place so I took the overkill approach and just put the entire mysql folder where the libs should be and modified the mysql_config file to point to the new place.</p>
<p>Good news is installing DBD is easy &#8211; If this is your first time installing anything from CPAN, you will go though a CPAN setup, just take all the defaults (there are a lot of questions) the ones that don&#8217;t have defaults, just take the obvious answers (like country to download files from)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-MCPAN</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'install DBI'</span></pre></div></div>

<p>Installing DBD::mysql is the problem &#8211; go ahead and try to install it anyway</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-MCPAN</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'install DBD::mysql'</span></pre></div></div>

<p>Do the following to fix it.</p>
<ul>
<li> get the MAMP source &#8211; Source forge link is &#8211; <a title="http://sourceforge.net/project/showfiles.php?group_id=121134&amp;package_id=132117" rel="nofollow" href="http://sourceforge.net/project/showfiles.php?group_id=121134&amp;package_id=132117">http://sourceforge.net/project/showfiles.php?group_id=121134&amp;package_id=132117</a></li>
<li> For MAMP 1.7.2 you need MySQL 5.0.41</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ curl <span style="color: #660033;">-O</span> http:<span style="color: #000000; font-weight: bold;">//</span>internap.dl.sourceforge.net<span style="color: #000000; font-weight: bold;">/</span>sourceforge<span style="color: #000000; font-weight: bold;">/</span>mamp<span style="color: #000000; font-weight: bold;">/</span>MAMP_1.7.2_src.zip</pre></div></div>

<ul>
<li> Once you have it downloaded, unzip it, then find mysql and un-tar.gz it, go in it, get the include and lib files and copy them out</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">unzip</span> MAMP_1.7.2_src.zip
$ <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> __MACOSX
$ <span style="color: #7a0874; font-weight: bold;">cd</span> MAMP_1.7.2_src
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvzf</span> mysql-5.0.41.tar.gz
$ <span style="color: #7a0874; font-weight: bold;">cd</span> mysql-5.0.41
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>mysql
$ .<span style="color: #000000; font-weight: bold;">/</span>configure
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-r</span> include<span style="color: #000000; font-weight: bold;">/*</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..
$ <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql.disabled
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-r</span> mysql-5.0.41 <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>lib
$ <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysql_config
&nbsp;
... <span style="color: #000000; font-weight: bold;">set</span> pkglibdir around line <span style="color: #000000;">86</span> to be <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>mysql-5.0.41<span style="color: #000000; font-weight: bold;">/</span>libmysql ...
&nbsp;
$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>.cpan<span style="color: #000000; font-weight: bold;">/</span>build<span style="color: #000000; font-weight: bold;">/</span>DBD-mysql-<span style="color: #000000;">4.010</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">rm</span> mysql.xsi
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> Makefile.PL <span style="color: #660033;">--testuser</span>=<span style="color: #7a0874; font-weight: bold;">test</span> --mysql_config=<span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>mysql_config
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
$ <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>Applications<span style="color: #000000; font-weight: bold;">/</span>MAMP<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>mysql.sock</pre></div></div>

<p>I don&#8217;t think that symlink will survive a restart though since mysql.sock is destroyed UPDATE: it doesn&#8217;t&#8230;</p>
<h2><span> </span><span> Install PERL CGI </span></h2>
<p>is easy</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">perl</span> <span style="color: #660033;">-MCPAN</span> <span style="color: #660033;">-e</span> <span style="color: #ff0000;">'install CGI'</span></pre></div></div>

<h2><span> </span><span>Available Tools </span></h2>
<p>MAMP comes with all sorts of goodies, just look in <code>/Applications/MAMP/bin</code> and <code>/Applications/MAMP/Library/bin</code> to see them all.  Here are some of the ones I use most commonly:</p>
<ul>
<li> To start Apache: <code>$ sudo apachectl start</code></li>
<li> To stop Apache: <code>$ sudo apachectl stop</code></li>
<li> To restart Apache: <code>$ sudo apachectl restart</code></li>
<li> To view all Apache vhosts: <code>$ apachectl -t -D DUMP_VHOSTS</code></li>
<li> To start MySQL: <code>$ startMysql.sh &amp;</code></li>
<li> To stop MySQL: <code>$ stopMysql.sh</code></li>
<li> To view domain names in a log file:</li>
<li> There are two ways to do this, and it is a two step process both ways
<ul>
<li> Method 1: This is the typical way to view one log file</li>
</ul>
</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ logresolve <span style="color: #660033;">-s</span> ~<span style="color: #000000; font-weight: bold;">/</span>resolvedlog.txt <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>mamp<span style="color: #000000; font-weight: bold;">/</span>log_filename
$ <span style="color: #c20cb9; font-weight: bold;">cat</span> ~<span style="color: #000000; font-weight: bold;">/</span>resolvedlog.txt</pre></div></div>

<ul>
<li>
<ul>
<li> Method 2: This is the only way to view multiple logs since using a wildcard in the above syntax will generate an error</li>
</ul>
</li>
</ul>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>mamp<span style="color: #000000; font-weight: bold;">/</span>log_<span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000; font-weight: bold;">|</span> logresolve <span style="color: #660033;">-s</span> ~<span style="color: #000000; font-weight: bold;">/</span>resolvedlog.txt<span style="color: #000000; font-weight: bold;">&lt;/</span>code<span style="color: #000000; font-weight: bold;">&gt;</span>
$ <span style="color: #c20cb9; font-weight: bold;">cat</span> ~<span style="color: #000000; font-weight: bold;">/</span>resolvedlog.txt</pre></div></div>

<ul>
<li> MAMP Admin Page: <a title="http://localhost/MAMP/" rel="nofollow" href="http://localhost/MAMP/">http://localhost/MAMP/</a> (should work w/ any vhost you have configured)</li>
<li> APC: <a title="http://localhost/MAMP/frame.php?src=apc.php" rel="nofollow" href="http://localhost/MAMP/frame.php?src=apc.php">http://localhost/MAMP/frame.php?src=apc.php</a></li>
<li> PHPMyAdmin: <a title="http://localhost/PhpMyAdmin/" rel="nofollow" href="http://localhost/PhpMyAdmin/">http://localhost/PhpMyAdmin/</a> or <a title="http://localhost/MAMP/frame.php?src=%2FphpMyAdmin%2F%3Flang%3Den-iso-8859-1" rel="nofollow" href="http://localhost/MAMP/frame.php?src=%2FphpMyAdmin%2F%3Flang%3Den-iso-8859-1">http://localhost/MAMP/frame.php?src=%2FphpMyAdmin%2F%3Flang%3Den-iso-8859-1</a></li>
<li> PHPInfo: <a title="http://localhost/MAMP/frame.php?src=info.php" rel="nofollow" href="http://localhost/MAMP/frame.php?src=info.php">http://localhost/MAMP/frame.php?src=info.php</a></li>
<li> SQLiteManager: <a title="http://localhost/MAMP/frame.php?src=%2FSQLiteManager%2F" rel="nofollow" href="http://localhost/MAMP/frame.php?src=%2FSQLiteManager%2F">http://localhost/MAMP/frame.php?src=%2FSQLiteManager%2F</a></li>
</ul>
<h2><span> </span><span> FAQ </span></h2>
<h3><span> </span><span>Why do you do all these settings and not just use the defaults setup by MAMP </span></h3>
<p>You could, well some of them. You don&#8217;t want to use the non-standard ports and you want everything to startup on boot, not on login of a user, and you want to have some command line access to control the servers. Much of the other settings, like all the symlinks, I mainly just do it be more &#8216;standard&#8217; so that things are where I expect them to be in the unix filesytem, not all tucked away inside of /Applications/MAMP/</p>
<h2><span> </span><span> References </span></h2>
<p>I wish I could say that I just knew all this but I didn&#8217;t.</p>
<p>I found two articles that combined together gave me the solution to get MAMP to start silently on boot.</p>
<ul>
<li> <a title="http://stringfoo.com/2008/08/25/tutorial-launching-mamp-silently-on-startup/" rel="nofollow" href="http://stringfoo.com/2008/08/25/tutorial-launching-mamp-silently-on-startup/">http://stringfoo.com/2008/08/25/tutorial-launching-mamp-silently-on-startup/</a></li>
<li> <a title="http://linsec.ca/blog/2006/11/22/mamp-and-php-development-on-the-mac/" rel="nofollow" href="http://linsec.ca/blog/2006/11/22/mamp-and-php-development-on-the-mac/">http://linsec.ca/blog/2006/11/22/mamp-and-php-development-on-the-mac/</a></li>
</ul>
<p>I found a couple of posts on getting DBD::MySQL working, these were the most helpful</p>
<ul>
<li> <a title="http://forum.webedition.de/phpBB/viewtopic.php?t=1204&amp;highlight=dbd#p10223" rel="nofollow" href="http://forum.webedition.de/phpBB/viewtopic.php?t=1204&amp;highlight=dbd#p10223">http://forum.webedition.de/phpBB/viewtopic.php?t=1204&amp;highlight=dbd#p10223</a></li>
<li> <a title="http://bugs.mysql.com/bug.php?id=30121" rel="nofollow" href="http://bugs.mysql.com/bug.php?id=30121">http://bugs.mysql.com/bug.php?id=30121</a></li>
</ul>
<p><!--  NewPP limit report Preprocessor node count: 118/1000000 Post-expand include size: 0/2097152 bytes Template argument size: 0/2097152 bytes Expensive parser function count: 0/100 --> <!-- Saved in parser cache with key psyjinx_mediawiki:pcache:idhash:4-0!1!0!!en!2 and timestamp 20090729042018 --></div>
</div>
</div>
</div>
<p><script type="text/javascript">// <![CDATA[
   if (window.runOnloadHook) runOnloadHook();
// ]]&gt;</script></p>
<p><!-- Served in 0.128 secs. --></p>
]]></content:encoded>
			<wfw:commentRss>http://psyjinx.com/jyoung/2009/01/how-to-setup-a-mac-os-x-mamp-based-web-server/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>PHP Performance</title>
		<link>http://psyjinx.com/jyoung/2008/08/php-performance/</link>
		<comments>http://psyjinx.com/jyoung/2008/08/php-performance/#comments</comments>
		<pubDate>Mon, 18 Aug 2008 04:55:29 +0000</pubDate>
		<dc:creator>James Young</dc:creator>
				<category><![CDATA[performance]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://psyjinx.com/wp/?p=46</guid>
		<description><![CDATA[<p>I have some more PHP Performance notes somewhere, but this is all that I can find right now.</p>

Use for loops over foreach loops
Use &#8216; over &#8220;, unless you are parsing variables
Use echo over print

<p>For Loops
Use either of the following syntax for your for loops. They take about the same amount of time to execute</p>

$count = [...]]]></description>
			<content:encoded><![CDATA[<p>I have some more PHP Performance notes somewhere, but this is all that I can find right now.</p>
<ul>
<li>Use for loops over foreach loops</li>
<li>Use &#8216; over &#8220;, unless you are parsing variables</li>
<li>Use echo over print</li>
</ul>
<p><strong>For Loops</strong><br />
Use either of the following syntax for your for loops. They take about the same amount of time to execute</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$count</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$count</span> <span style="color: #339933;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$count</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p>DO NOT use the following, it is significantly slower:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$arr</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://psyjinx.com/jyoung/2008/08/php-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install PHP5 on Mac OS X 10.4.x</title>
		<link>http://psyjinx.com/jyoung/2007/05/install-php5-on-mac-os-x-10-4-x/</link>
		<comments>http://psyjinx.com/jyoung/2007/05/install-php5-on-mac-os-x-10-4-x/#comments</comments>
		<pubDate>Sat, 12 May 2007 19:47:23 +0000</pubDate>
		<dc:creator>James Young</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://psyjinx.com/wp/?p=58</guid>
		<description><![CDATA[
Install MySQL on Mac OS X if you haven&#8217;t already
Install XCode if you haven&#8217;t already
Do either this:

Open NetInfo Manager
Modify /groups/wheel/users, add a new value for your login id, this will come into play later

<p>or this:</p>

$ niutil -appendprop / /groups/wheel users yourloginid


Get PHP Complete Source Code from php.net &#8211; http://php.net/get/php-5.2.2.tar.gz/from/a/mirror (more current versions are out now)
Open [...]]]></description>
			<content:encoded><![CDATA[<ol>
<li><a href="http://psyjinx.com/jyoung/2007/05/install-mysql-on-mac-os-x-10-4-x/">Install MySQL on Mac OS X</a> if you haven&#8217;t already</li>
<li>Install XCode if you haven&#8217;t already</li>
<li>Do either this:
<ul>
<li>Open NetInfo Manager</li>
<li>Modify /groups/wheel/users, add a new value for your login id, this will come into play later</li>
</ul>
<p>or this:</p>
<ul>
<li><code>$ niutil -appendprop / /groups/wheel users yourloginid</code></li>
</ul>
</li>
<li>Get PHP Complete Source Code from php.net &#8211; <a href="http://php.net/get/php-5.2.2.tar.gz/from/a/mirror">http://php.net/get/php-5.2.2.tar.gz/from/a/mirror</a> (more current versions are out now)</li>
<li>Open it up on your desktop, leaving a php-[version] folder:<br />
<code>$ tar xvzf /path/to/php-[version].tar.gz</code></li>
<li>Look at your phpinfo.php file (details in Enable PHP on Mac OS X 10.4.x)</li>
<li>Copy the Configure Command</li>
<li>Paste it into a vim buffer and strip out the &#8216;
<ul>
<li>:%s/&#8217;//g</li>
<li>NOTE: <code>/SourceCache/apache_mod_php/apache_mod_php-18.8/php/configure</code> is not part of what we need</li>
<li>Remove the <code>--without-pear</code> and change <code>--with-mysql=/usr</code> to be <code>--with-mysql=/usr/local/mysql</code></li>
<li>Configure from my Mac OS X 10.4.9 Intel MBP Core Duo looks like this:

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--mandir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">man</span> <span style="color: #660033;">--infodir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>info <span style="color: #660033;">--disable-dependency-tracking</span> <span style="color: #660033;">--with-apxs</span> <span style="color: #660033;">--with-ldap</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--with-kerberos</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--enable-cli</span> <span style="color: #660033;">--with-zlib-dir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--enable-trans-sid</span> <span style="color: #660033;">--with-xml</span> <span style="color: #660033;">--enable-exif</span> <span style="color: #660033;">--enable-ftp</span> <span style="color: #660033;">--enable-mbstring</span> <span style="color: #660033;">--enable-mbregex</span> <span style="color: #660033;">--enable-dbx</span> <span style="color: #660033;">--enable-sockets</span> <span style="color: #660033;">--with-iodbc</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--with-curl</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--with-config-file-path</span>=<span style="color: #000000; font-weight: bold;">/</span>etc <span style="color: #660033;">--sysconfdir</span>=<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc <span style="color: #660033;">--with-mysql</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--with-mysql-sock</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>mysql.sock <span style="color: #660033;">--without-pear</span></pre></div></div>

</li>
</ul>
</li>
<li>Configure, make, make install, and setup the rest in terminal

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>lib
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> . mysql
$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>Desktop<span style="color: #000000; font-weight: bold;">/</span>php-<span style="color: #7a0874; font-weight: bold;">&#91;</span>version<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">/</span>
$ .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--mandir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">man</span> <span style="color: #660033;">--infodir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>share<span style="color: #000000; font-weight: bold;">/</span>info <span style="color: #660033;">--disable-dependency-tracking</span> <span style="color: #660033;">--with-apxs</span> <span style="color: #660033;">--with-ldap</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--with-kerberos</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--enable-cli</span> <span style="color: #660033;">--with-zlib-dir</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--enable-trans-sid</span> <span style="color: #660033;">--with-xml</span> <span style="color: #660033;">--enable-exif</span> <span style="color: #660033;">--enable-ftp</span> <span style="color: #660033;">--enable-mbstring</span> <span style="color: #660033;">--enable-mbregex</span> <span style="color: #660033;">--enable-dbx</span> <span style="color: #660033;">--enable-sockets</span> <span style="color: #660033;">--with-iodbc</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--with-curl</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--with-config-file-path</span>=<span style="color: #000000; font-weight: bold;">/</span>etc <span style="color: #660033;">--sysconfdir</span>=<span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc <span style="color: #660033;">--with-mysql</span>=<span style="color: #000000; font-weight: bold;">/</span>usr <span style="color: #660033;">--with-mysql-sock</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span>mysql.sock <span style="color: #660033;">--without-pear</span>
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini.default <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini</pre></div></div>

</li>
<li>Edit the php.ini to have the include_path line match the following:

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">include_path</span> <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;.:/php/includes:/usr/lib/php&quot;</span></pre></div></div>

</li>
<li>Edit httpd.conf to use PHP5, not PHP4 (as it does by default), basically change all instances of php4 to php5

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>httpd.conf</pre></div></div>

</li>
<li>Restart apahce: $ sudo apachectl restart</li>
<li>Verify PHP, MySQL, and Apache are playing nice.  Create a file with the following contents and confirm you get data back, not an error.  Name it something like mysqlphptest.php.  If you place it directly in your document root (/Library/WebServer/Documents) you can access it by going to http://localhost/mysqlphptest.php

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #990000;">mysql_pconnect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'localhost'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'root'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error: &quot;</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">mysql_select_db</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mysql'</span><span style="color: #009900;">&#41;</span> or <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error: &quot;</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: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_fetch_array</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">mysql_query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'SELECT * FROM user LIMIT 1'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</li>
<li>Get PEAR working &#8211; <a href="http://psyjinx.com/jyoung/2007/05/enable-pear-on-mac-os-x-10-4-x/">Enable PEAR on Mac OS X 10.4.x</a></li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://psyjinx.com/jyoung/2007/05/install-php5-on-mac-os-x-10-4-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enable PHP on Mac OS X 10.4.x</title>
		<link>http://psyjinx.com/jyoung/2007/05/enable-php-on-mac-os-x-10-4-x/</link>
		<comments>http://psyjinx.com/jyoung/2007/05/enable-php-on-mac-os-x-10-4-x/#comments</comments>
		<pubDate>Sat, 12 May 2007 19:41:07 +0000</pubDate>
		<dc:creator>James Young</dc:creator>
				<category><![CDATA[configuration]]></category>
		<category><![CDATA[macosx]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://psyjinx.com/wp/?p=54</guid>
		<description><![CDATA[<p>10.4.9
</p>

Edit the httpd.conf file
Uncomment the lines that contain php
Restart apache
Confirm it works via phpinfo.php
fix PEAR &#8211; see Enable PEAR on Mac OS X 10.4.x

<p>command summary of the above (assuming you know what to do in vim)</p>

$ sudo vim /etc/httpd/httpd.conf
$ sudo apachectl restart
$ vim /Library/WebServer/Documents/phpinfo.php

<p>phpinfo.php contents</p>

&#60;?php phpinfo&#40;&#41;; ?&#62;

]]></description>
			<content:encoded><![CDATA[<p><strong>10.4.9<br />
</strong></p>
<ol>
<li>Edit the httpd.conf file</li>
<li>Uncomment the lines that contain php</li>
<li>Restart apache</li>
<li>Confirm it works via phpinfo.php</li>
<li>fix PEAR &#8211; see <a href="http://psyjinx.com/jyoung/2007/05/enable-pear-on-mac-os-x-10-4-x/">Enable PEAR on Mac OS X 10.4.x</a></li>
</ol>
<p>command summary of the above (assuming you know what to do in vim)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>httpd<span style="color: #000000; font-weight: bold;">/</span>httpd.conf
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> apachectl restart
$ <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>WebServer<span style="color: #000000; font-weight: bold;">/</span>Documents<span style="color: #000000; font-weight: bold;">/</span>phpinfo.php</pre></div></div>

<p>phpinfo.php contents</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #990000;">phpinfo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://psyjinx.com/jyoung/2007/05/enable-php-on-mac-os-x-10-4-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
