Sponsor
Now Playing
- Alix Perez – I'm Free 3 hours ago
- Alix Perez – Intersections 3 hours ago
- Alix Perez – Forsaken 3 hours ago
- Glen E Ston – Ouroboros (Original Mix) 3 hours ago
- Black Sun Empire – Everything 4 hours ago
Tutorial: Doing basic MySQL database stuff
April 8, 2008,
476 views
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
';
} 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