View Full Version : Connect to outside database?
liamallan
03-11-2010, 05:31 PM
how do i connect to an outside database (not localhost)? database is on freehostia.com
define("DB_SERVER", "mysql4.freehostia.com");
define("DB_USER", "liaall_users");
define("DB_PASS", "**********");
define("DB_NAME", " liaall_users");
hmsnacker123
04-18-2010, 04:58 PM
Try this:
<?php
$connection = mysql_connect("mysql4.freehostia.com", "username", "password") or die(mysql_error());
mysql_select_db("database_name", $connection) or die(mysql_error());
// Rest of your script here.
mysql_close($connection);
?>
That usually work's, if it doesen't, then post the error info here (delete sensitive info of course). Then I or someone else can help you.
Hope I helped.
Edit: This is mysql_connect etc. using your defines
<?php
define("DB_SERVER", "mysql4.freehostia.com");
define("DB_USER", "liaall_users");
define("DB_PASS", "**********");
define("DB_NAME", " liaall_users");
$connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die(mysql_error());
mysql_select_db(DB_NAME, $connection) or die(mysql_error());
// Rest of your script here.
mysql_close($connection);
?>
akitodito
04-20-2010, 04:47 PM
can you connect to database through command line with mysql command
hmsnacker123
04-21-2010, 03:06 AM
can you connect to database through command line with mysql command
Yes, you can:
mysql -u DBUSER -h DBSERVERNAME -p
Where:
DBUSER = Your MySql Username. Usually: root
DBSERVERNAME = The Location Of Your MySql server. Usually: localhost
Assuming that you are using Windows.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.