|
-
May 4th, 2008, 01:16 PM
#1
Thread Starter
New Member
Connect to MySQL Database
MySQL is a database that goes hand-in-hand with PHP.
This is for People here who dont know how to connect to MySQL.
You will need it in many PHP development situations.
PHP Code:
<?php
$dbserver = "localhost";
//if you do not know your database server then try localhost
//You can find information of your mysql database at the PhpMyAdmin Panel
$dbusername = "dbusername";
$dbname = "dbname";
$dbpass = "dbpassword";
$connect = mysql_connect($dbserver,$dbusername,$dbpass); //Connects
$selectdb = mysql_select_db($dbname); \\Selects desired DataBase
if(!$connect || !$selectdb){ //If one or both of the mysql functions fail
die("Cannot connect: " . mysql_error()); //Display error
}
else{ //If no errors occur
echo "You have connected to a database!";
}
?>
HTML portion of webpage that uses MySQL data
<?php mysql_close(); //disconnect ?>
Hope this was helpful
Last edited by Killsoft69; May 4th, 2008 at 01:35 PM.
-
May 4th, 2008, 02:03 PM
#2
Fanatic Member
Re: Connect to MySQL Database
Welcome to The Forum & Have a look Here
Thanks !
-
May 4th, 2008, 03:06 PM
#3
Re: Connect to MySQL Database
welcome to vbf! We have lots of examples of MySQL code here on the forums.
My usual boring signature: Something
-
May 5th, 2008, 10:33 AM
#4
Thread Starter
New Member
Re: Connect to MySQL Database
 Originally Posted by dclamp
> We have lots of examples of MySQL code here on the forums.
Yeah, I guess I should looked for tutorials on the same subject before I posted mine.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|