View Full Version : How to Connect to my database
I am learning php/mysql and want to write a simple script. What is a good way to connect to my database in a php script?
03-17-2005, 07:58 PM
Opening a connection to MySQL database from PHP is easy. Just use the mysql_connect() function like this:
$dbhost = 'localhost';
$dbuser = 'username';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'yourdatabasename';
vBulletin® v3.7.4, Copyright ©2000-2013, Jelsoft Enterprises Ltd.