Page 1 of 1

how do i connect to a remote database

Posted: Thu Dec 09, 2004 5:57 pm
by Kingo
Hello,
As i did not have the database, i'm using an online free database.
These people gave me the following info

http://www.freesql.org
port 3306
database name : xxx
user: yyy
password: zzz

How do i connect to the database?

Posted: Thu Dec 09, 2004 6:08 pm
by kettle_drum

Code: Select all

$db = mysql_connect("www.freesql.org:3306", "yyy", "zzz") or die("Cannot connect to database.");
mysql_select_db("xxx", $db) or die("Couldn't select database.");

Posted: Thu Dec 09, 2004 6:12 pm
by Chris Corbyn
Firstly... make sure your free Hosting service doesn't have the mysql functions disabled. I know T35.com have them disabled for the free service.

If they're not then you just use

Code: Select all

$server = "www.freesql.org";
$user = "xxxxx";
$pass = "xxxxx";
$database = "xx";
$port = "3306"; //The default port so you don't really need to specifiy it

$connect = mysql_connect($server . ':' . $port, $user, $pass); //looks like http://www.freesql.org:3306,xxxxx,xxxxx
mysql_select_db($database);

mysql_close($connect); //at the end of using the db

?>
Voila. But check the functions are enabled first! ;-)

Posted: Thu Dec 09, 2004 6:14 pm
by Chris Corbyn
I notice a lot of british people are still up at this time! Everyone busy trying to cram lots of work in before xmas or something :-D ?

thread hijack - xmas

Posted: Thu Dec 09, 2004 7:15 pm
by timvw
bleh :P

beautiful women cost a lot of money, so i gotta make lots of money ;)) and make some programs in http://euler.sf.net as a replacement for my math exam in january...

ah well, you can http://home.mysth.be/~timvw/demo (user: timvw pass: password) (packages -> select a package and choose maintain files -> choose create). the idea is that users can create packages, and those packages can contain files they have on their server.... we want to make it as easy as possible, therefore they only have to install 1 file on their server... and pass us the url of where that file is located...