Please visit our sponsor
UNKNOWN //************************************** // for :Easy To Understand MySQL Connection //************************************** OPEN SOURCE, but Credit would be nice. :) //************************************** // Name: Easy To Understand MySQL Connection // Description:This is to teach you how to connect to your mysql database and select a table. I have made it very clean and added comments to help you understand the process. // By: Todd Williams // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //This code is copyrighted and has limited warranties. //Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.315/lngWId.8/qx/vb/scripts/ShowCode.htm //for details. //************************************** <?php $server= ""; //ie: mysql.server.net $username = ""; //ie: jonnhy $password = ""; //ie: password101 $databasename = ""; //ie: jonnydata $tablename= ""; //ie: emails $connection = mysql_connect("$server","$username","$password"); if(!$connection)// are we not connected? { echo "Couldn't make a connection!!!"; exit; //exits the script } $db = mysql_select_db("$databasename",$connection); if(!$db) //was the database not found? { echo "The database disapeared!"; mysql_close($connection); //closes connection exit; // exits the code } echo "If you can see this you are connected to your database and your table is selected.";