PHP and MySQL

<?php

//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.

{

echo $row['Col1'];

echo ‘<br/>';

echo $row['Col2'];

// echoing $row['NameOfColumn']; will echo the results from each cell in the named column.

}

?>

Basic PHP

The first PHP file

<?php

//this is a one line comment

/*this is a

multiline comment*/

function FirstFunction()

{

echo “My first “;

$Variable = “String.<br/>”;

echo $Variable;

$FirstBoolenArray = array(1,2,3,4,5);

print_r($FirstBoolenArray);

$NewVariabe = “<br/>New String<br/>”;

$BoolenVariable = 1;

print $NewVariable;

print $BoolenVariable;

echo”<table><tr><td>Table</td></tr></table>”;

}

?>

Go ahead and run this program by following the steps found in Using WAMP to Test PHP.

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!

Introduction and Intent

Hey Reader!

Louis Milotte here and this will be my blog to house software that i’ve written or studied/currently reading about. I’m big into PHP,MySQL, Javascript, XML etc. pretty much… if it has a big presence on the web developer world.. i like to read about it. Everything posted here will be free to use manipulate and critique.