PDA

View Full Version : PHP connecting to MySQL


ksdp3665
10-23-2004, 10:20 PM
Hi,

I am a newbie..... Sorry...

Anyway, I have sample PHP code to help me setup a database oriented website. But, the samples all connect to the database server using 'localhost'. If the database is being served by a web hosting company, and the PHP code has been uploaded to the site, what parameters should be used in the "@ $db = new mysqli" line of code?

Any help is appreciated.

Scott

Archangel
10-25-2004, 07:08 AM
You'll need to figure out what the hosting company uses or wants you to use.

Terry
10-25-2004, 12:16 PM
'localhost' is correct for a web hosted database.

ksdp3665
10-25-2004, 10:33 PM
Thanks for the replies. I can't seem to make 'localhost' work. Any additional direction or assistance is GREATLY appreciated!

Thanks in advance...

Scott

Terry
10-26-2004, 12:27 AM
Here's an example that works:


<?
$hostname = "localhost";
$database = "user_acctmgr";
$user = "user_accounts";
$pass = "manager";

$connection = mysql_connect($hostname, $user, $pass) or die ("Unable to connect!");
?>