<?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>Beerwin&#039;s blog &#187; PHP</title>
	<atom:link href="http://www.blog.beerwin.com/category/tutorials/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blog.beerwin.com</link>
	<description>Beerwin&#039;s World of Stuff blog - things that have no place on the main site</description>
	<lastBuildDate>Sat, 15 Oct 2011 00:49:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Connecting to a MySQL database with PHP</title>
		<link>http://www.blog.beerwin.com/2008/05/04/connecting-to-a-mysql-database-with-php/</link>
		<comments>http://www.blog.beerwin.com/2008/05/04/connecting-to-a-mysql-database-with-php/#comments</comments>
		<pubDate>Sun, 04 May 2008 11:58:03 +0000</pubDate>
		<dc:creator>beerwin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutorials]]></category>

		<guid isPermaLink="false">http://www.beerwin.com/blog/?p=4</guid>
		<description><![CDATA[In this tutorial, i will tell, how to connect to an existing MySQL database with an existing username and password. For the first, we need the database and the credentials for it. If you are using a free web hosting service with PHP and MySQL support, you already have this information. If you have a [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial, i will tell, how to connect to an <strong>existing </strong>MySQL database with an existing username and password.</p>
<p>For the first, we need the database and the credentials for it. If you are using a free web hosting service with PHP and MySQL support, you already have this information.</p>
<p>If you have a web server installed with PHP and MySQL, you have to create a database and a username. Since this is not part of this tutorial i will talk about it in another post.</p>
<p>Now, it&#8217;s time to get connected. We will create the <strong>db.inc.php </strong>file:</p>
<div style="border:1px solid #C0C0C0; background-color:#FFFFFF; overflow:auto; height:250px;">
<div style="width: 50px; float: left; background-color: #dedede; font-family: monospace; line-height: 18px; text-align: right; padding-right: 5px; margin-right: 1px;">1<br />
2<br />
3<br />
4<br />
5<br />
6<br />
7<br />
8<br />
9<br />
10<br />
11<br />
12<br />
13</div>
<div style="background-color: #FFFFFF; font-family: monospace; line-height: 18px; text-align: left; border-left:1px solid #CCCCCC; margin-left:1px;"><span style="color: #000080;"><span style="color: #008080;">//database connection file// for first, we need to set database name, host, username and password for our connection. Modify them corresponding to your data.<br />
</span><br />
$dbhost</span>=<span style="color: #ff00ff;">&#8220;localhost&#8221;</span>;<span style="color: #000080;"><br />
$dbusername</span>=&#8221;<span style="color: #ff00ff;">your_username&#8221;</span>;<span style="color: #000080;"><br />
$dbpassword</span>=<span style="color: #ff00ff;">&#8220;yourpassword&#8221;</span>;<span style="color: #000080;"><br />
$db</span>=<span style="color: #ff00ff;">&#8220;your_db&#8221;</span><span style="color: #000080;">;<br />
</span><span style="color: #000080;"><br />
<span style="color: #008080;">//If you filled in your data, it&#8217;s time to make the connection. Don&#8217;t modify anything below this line</p>
<p></span></span></div>
<div style="background-color: #FFFFFF; font-family: monospace; line-height: 18px; text-align: left; border-left:1px solid #CCCCCC; margin-left:1px;"><span style="color: #000080;">$connector</span> = <span style="color: #ff0000;">mysql_connect</span>(<span style="color: #000080;">$dbhost</span>, <span style="color: #000080;">$dbusername</span>, <span style="color: #000080;">$password</span>) <span style="color: #ff0000;">or die</span>(<span style="color: #ff00ff;">&#8216;</span><span style="color: #ff00ff;">Could not connect to MySQL!</span><span style="color: #ff00ff;">&#8216;</span>);</p>
<p><span style="color: #000080;">$db</span> = <span style="color: #ff0000;">mysql_select_db</span>(<span style="color: #000080;">$db</span>, <span style="color: #000080;">$connector</span>) <span style="color: #ff0000;">or die</span>(<span style="color: #ff00ff;">&#8220;Couldn&#8217;t select database.&#8221;</span>);</p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.blog.beerwin.com/2008/05/04/connecting-to-a-mysql-database-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

