Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: how to connect to MySQL Database
06-16-2009, 06:21 AM #1
- Join Date
- May 2009
- Thanked 1 Time in 1 Post
how to connect to MySQL Database
i've reading and practicing a little with PHP and MySQL. i've set-up a local environment for the exercises. i've been fairly often using the code :
$connection = mysql_connect('localhost', 'root', 'pass') or die('unable to connect');
06-16-2009, 06:35 AM #2
- Join Date
- Oct 2006
- Denver, Colorado USA
- Thanked 319 Times in 311 Posts
It can be 'localhost' if that is what has been configured, or it can be the DNS name of the mysql server, or it can be the IP address of the mysql server. Which one of these depends on how the web host has setup the web server/mysql server. The best way to determine which one would be to consult the web host's documentation.
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
Users who have thanked CFMaBiSmAd for this post: