<?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>NewSourceMedia Blog &#187; information</title>
	<atom:link href="http://newsourcemedia.com/blog/tag/information/feed/" rel="self" type="application/rss+xml" />
	<link>http://newsourcemedia.com/blog</link>
	<description>Focused on Interactive Design, Development and Marketing</description>
	<lastBuildDate>Mon, 07 May 2012 01:26:28 +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>Create MySQL Database With PHP</title>
		<link>http://newsourcemedia.com/blog/create-mysql-database-with-php/</link>
		<comments>http://newsourcemedia.com/blog/create-mysql-database-with-php/#comments</comments>
		<pubDate>Tue, 26 Dec 2006 00:22:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[MySQL / Database]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[access]]></category>
		<category><![CDATA[base]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[information]]></category>
		<category><![CDATA[myslq]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[store]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://newsourcemedia.com/blog/2006/12/25/create-mysql-database-with-php/</guid>
		<description><![CDATA[Create a dynamic web site by using MySQL Database and PHP. It is easy and I provided the code to cut and paste. Now let get started with PHP and MySQL code for building a Dynamic Web Site: PHP &#38; &#8230; <a href="http://newsourcemedia.com/blog/create-mysql-database-with-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[Create a dynamic web site by using MySQL Database and PHP. It is easy and I provided the code to cut and paste.<span id="more-179"></span>

Now let get started with PHP and MySQL code for building a Dynamic Web Site:
<h3>PHP &amp; database connection code in a lib file for inclusion</h3>
1) First we make a php file called "lib.php"
2) Then we add the following php code to the lib.php file for making a connection to the database. Be sure to change the names to match your host name, user name, password and database name :

<span class="code">&lt;?
$dbhost = 'localhost';
$dbuser = 'myusername'; // you must set user name!
$dbpass = 'mypassword'; // you must set pass word!
$dbname = 'car_database'; // you must set database or fill-in database name in the form!</span>
<p class="code">function dbconnect()
{
global $dbhost, $dbuser, $dbpass, $dbname;
mysql_pconnect($dbhost, $dbuser, $dbpass);
@mysql_select_db($dbname) or die ("Unable to select database");
}

<p class="code">function query_db($query)
{
dbconnect();
return @mysql_query($query);
}
?&gt;
<h3>Database Manager (PhpMyAdmin) to create a new table</h3>
3) Open up your database manager (PhpMyAdmin) and select your database, then click the SQL tab or icon for running a SQL query and copy and paste the following code in the text field then click the "Go" or "Submit" button to create the <em>car_table</em> database.
<p class="code">CREATE TABLE car_table (</p>

<p class="code">car_make varchar(250) default NULL,
car_model varchar(250) default NULL,
car_year varchar(250) default NULL,
id_field int(11) NOT NULL auto_increment,
PRIMARY KEY (id_field)
) TYPE=MyISAM;
<h3>PHP code for managing your table fields</h3>
4) <span class="code">Download Code file "cars.txt" here: <a href="../../New%20Tutorials/cars.txt" target="_blank">http://newsourcemedia.com/New Tutorials/cars.txt</a></span>

5)  Rename that file to "cars.php". Notice that the first line of code is there to imports your first file "lib.php". Why? Because for every php file that query's the database will need to make a database connection. So why not use one file to make that connection for all php files.

6) Uploads both the "lib.php" and the "cars.php" to your web server. Make sure both files are in side of the same directory.
<h3>Third PHP file for visitors without the edit or delete functions.</h3>
7) After adding content to your database, you may want to make a third file called "viewcars.php" for the users to view the database list of cars. Do this by duplicating the "cars.php" file. But be sure to <strong>delete </strong>all of the links labeled "delete", "edit" and "add" and remove all php blocks of code that start with "<span class="code">$query=INSERT INTO...</span>, <span class="code">$query=UPDATE...</span>, and <span class="code">$query=DELETE FROM...</span>" to provent visitors from editing your database content.]]></content:encoded>
			<wfw:commentRss>http://newsourcemedia.com/blog/create-mysql-database-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
