<?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>Alex Briffett &#187; mysql4</title>
	<atom:link href="http://www.briffett.net/tag/mysql4/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.briffett.net</link>
	<description>Life is just a state of mind</description>
	<lastBuildDate>Wed, 17 Feb 2010 14:21:19 +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>PHP 5+ and MySQL 4.0 Could not connect</title>
		<link>http://www.briffett.net/2010/01/14/php-5-and-mysql-4-0/</link>
		<comments>http://www.briffett.net/2010/01/14/php-5-and-mysql-4-0/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 11:40:18 +0000</pubDate>
		<dc:creator>Alex Briffett</dc:creator>
				<category><![CDATA[Web Code]]></category>
		<category><![CDATA[Could not connect]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[mysql4]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php5]]></category>

		<guid isPermaLink="false">http://www.briffett.net/?p=242</guid>
		<description><![CDATA[I got the following error: Could not connect: Connecting to 3.22, 3.23 &#038; 4.0 servers is not supported]]></description>
			<content:encoded><![CDATA[<p>Hopefully you should never encounter this problem but I recently needed to do an insert into a MySQL 4.0 table from a remote installation of PHP 5.  I could connect from the PHP5 server to the MySQL 4.0 server via the command line, so assumed this would work find using PHP5.</p>
<p>I got the following error: Could not connect: Connecting to 3.22, 3.23 &amp; 4.0 servers is not supported</p>
<p>Basically, later versions of PHP use a password encryption algorithm which means they are incompatible with MySQL 4.0 but not MySQL 4.1+.</p>
<p>Since the command line connection worked, the solution was to create a shell script on the PHP5 server which looked similar to the following:</p>
<div style="padding: 10px; background-color: #eee;">
<p style="padding-left: 30px;"><strong>#!/bin/sh</strong></p>
<p style="padding-left: 30px;"><strong>/usr/bin/mysql -u USERNAME -pPASSWORD DBNAME -h HOST&lt;&lt;STOP<br />
insert into table (name, email) values ('$1','$2')<br />
\g<br />
STOP<br />
exit</strong></p>
</div>
<p>You will need to swap the capitalized variables for your own USERNAME, PASSWORD, DBNAME and HOST.</p>
<p>I called the shell script doinsert.sh and chmodded it 755 to make it executable.  Then, in my PHP script I used:</p>
<div style="padding: 10px; background-color: #eee;">
<p style="padding-left: 30px;"><strong>&lt;?php<br />
</strong></p>
<p style="padding-left: 30px;"><strong>$r = shell_exec('./doinsert.sh ' . $name . " " . $email);</strong></p>
<p style="padding-left: 30px;"><strong>?&gt;</strong></p>
</div>
<p>...which executes the shell script and runs the insert statement I was aiming for.  If you want to run a select statement instead of my insert example, then anything returned by the shell script should be available in $r.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Bookmark It | Post It | Share It</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blinklist.com/index.php?Action=Blink/addblink.php&amp;Name=PHP+5%2B+and+MySQL+4.0+Could+not+connect&amp;Description=PHP+5%2B+and+MySQL+4.0+Could+not+connect&amp;Url=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F" rel="nofollow" title="Add to&nbsp;BlinkList"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/blinklist.png" title="Add to&nbsp;BlinkList" alt="Add to&nbsp;BlinkList" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.bloglines.com/sub/http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F" rel="nofollow" title="Add to&nbsp;Bloglines"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/bloglines.png" title="Add to&nbsp;Bloglines" alt="Add to&nbsp;Bloglines" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://blogmarks.net/my/new.php?mini=1&amp;simple=1&amp;url=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;title=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Blogmarks"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/bmarks.png" title="Add to&nbsp;Blogmarks" alt="Add to&nbsp;Blogmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;submitHeadline=PHP+5%2B+and+MySQL+4.0+Could+not+connect&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.connotea.org/addpopup?continue=confirm&amp;uri=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;title=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Connotea"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/connotea.png" title="Add to&nbsp;Connotea" alt="Add to&nbsp;Connotea" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;title=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.diigo.com/post?url=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;title=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Diigo"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/diigo.png" title="Add to&nbsp;Diigo" alt="Add to&nbsp;Diigo" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;title=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://cgi.fark.com/cgi/fark/farkit.pl?u=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;h=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Fark"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/fark.png" title="Add to&nbsp;Fark" alt="Add to&nbsp;Fark" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://fleck.com/litebookmarklet.php?url=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;title=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Fleck"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/fleck.png" title="Add to&nbsp;Fleck" alt="Add to&nbsp;Fleck" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;title=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;bm_description=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;title=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;title=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Slashdot"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/slashdot.png" title="Add to&nbsp;Slashdot" alt="Add to&nbsp;Slashdot" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;title=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.spurl.net/spurl.php?url=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;title=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Spurl"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/spurl.png" title="Add to&nbsp;Spurl" alt="Add to&nbsp;Spurl" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+PHP+5%2B+and+MySQL+4.0+Could+not+connect+@+http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.briffett.net%2F2010%2F01%2F14%2Fphp-5-and-mysql-4-0%2F&amp;t=PHP+5%2B+and+MySQL+4.0+Could+not+connect" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.briffett.net/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.briffett.net/2010/01/14/php-5-and-mysql-4-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.316 seconds -->
