Tutorial: Doing basic MySQL database stuff

Meta: April 08th 2008 // PHP

This tutorial is quite easy. If you want to connect to a mysql database you can use something like this:

$host = 'localhost';
$username = 'yourusername';
$password = 'yourpassword';
$databasename = 'yourdbname';
 
//don't edit this stuff okay?
 
$connect = mysql_connect($host, $username, $password);
$selectdb = mysql_select_db($databasename);
 
if($connect == true){
	echo 'Connected fine!';
} else {
	echo 'Bad Username or Password.....or host dummy!!!!';
}
 
if($selectdb == true){
	echo 'Connected to DB master :D';
} else {
	echo 'Cant find that database....did we connect?';
}

So this code basically connects to the database and says hi!
More to come on DB Functions ;)

Postscript: Leave A Comment // Subscribe (RSS Feed)

Want To Be Heard? Comment Here!

// I Love Comments, Especially Nice Ones

Who Are You?

Your Email Address

Your Website

:D :) :o :eek: :( :lol: :wink: :arrow: :idea: :?: :!: :evil: :p

You can follow any responses to this entry via its RSS comments feed. You may also leave a trackback by clicking this link.