Web Hosting Talk







View Full Version : Connecting to db


bullethead
03-06-2003, 02:01 PM
I have a database named "bullethead_net".

I want to use that db on another website (on a different server).
(I can't create a db on the other server)

//MySQL info
$db_name = "bullethead_net";
$host = "localhost";
$db_user = "myUsername";
$db_password = "myPassword";

What do I replace "localhost" with?

cortices
03-06-2003, 03:16 PM
The original server's hostname?

bullethead
03-06-2003, 03:33 PM
Could you give me an example of what a hostname looks like?

sasha
03-06-2003, 03:37 PM
webhostingtalk.com <= host name

jkca
03-06-2003, 04:03 PM
Originally posted by bullethead
I have a database named "bullethead_net".

I want to use that db on another website (on a different server).
(I can't create a db on the other server)

//MySQL info
$db_name = "bullethead_net";
$host = "localhost";
$db_user = "myUsername";
$db_password = "myPassword";

What do I replace "localhost" with?

How about 127.0.0.1

summcat
03-06-2003, 08:20 PM
this is a DB connection i use for something, as an example:

<?php
$user = "username";
$pass = "password";
$db = "markp_phpbb";
$link = mysql_connect( "localhost:, $user, $pass );
if ( ! $link )
die( "Couldn't connect to the Database" );
print "Successfully connected to the phpBB server";
mysql_select_db( $db )
or die ( "Couldnt open $db: ".mysql_error() );
print "Sucessfully selected database \"$db\";
mysql_close( $link );

?>

S. Jackson
03-06-2003, 09:35 PM
cat /etc/hosts

127.0.0.1 <hostname>