//This document displays how PHP can interact with MySQL.
$con = mysql_connect(“localhost”,”root”,””) or die(mysql_error());
//the or die() function will throw an error if the connection fails. This can be added to the SQL calls made in this file.
//with WAMP basic settings the above will connect to the Virtualized MySQL Server
$db = mysql_select_db(“MyDB”);
//Without first creating a Database by the name of MyDB in phpmyadmin this will throw an error.
$sql = mysql_query(“SELECT * FROM MyTable”);
//This pulls all the data from the MyTable Table.
while ($row = mysql_fetch_array($sql))
//This will make $row the variable to call the data from the database.
// echoing $row[‘NameOfColumn’]; will echo the results from each cell in the named column.
The first PHP file
//this is a one line comment
/*this is a
echo “My first “;
$Variable = “String.<br/>”;
$FirstBoolenArray = array(1,2,3,4,5);
$NewVariabe = “<br/>New String<br/>”;
$BoolenVariable = 1;
Go ahead and run this program by following the steps found in
Using WAMP to Test PHP.
This article lays out how to test your PHP files using the virtual environment known as WAMP. For more on WAMP go to their website at
www.wampserver.com/en/ to install this application go to: http://www.wampserver.com/en/#download-wrapper .
After installing WAMP open the file directory where your projects will be stored. commonly this is found at c:\wamp\www\ .
Now, use your favorite program to construct your PHP files and don’t forget to keep reading my posts on tutorials!
This entry was posted in