Page 1 of 1

Php will not connect to old database

Posted: Mon Jan 23, 2006 1:32 pm
by slowpoke
I don’t know if this is the place for this question?:?: It may depend on the answer. :D

I just put a new server in with php5.0.4 and can only connect to the MySql database on the localhost. It will not connect to another MySql database. It will not even connect to the localhost database if I use the IP address instead of the name ‘localhost’.

MySql will connect to a remote host if I use a command line through MySql so I know the database is fine. I think it is my php config or maybe I need to add something to my code?

Here is the code that runs on my server running php4.2.2
This code also works for the local database if I change the variables to fit this server.

Code: Select all

require("../functions/db.php");
$wwwdb_name = get_db_name();  //returns the db name
$wwwtable_name = "ITEM";
$wwwhostname = get_db_hostname(); //returns the host name or address
$wwwusername = get_db_username(); //returns the user name.
$wwwsql_password = get_db_password(); //returns the pw
$wwwconnection = @mysql_connect($wwwhostname, $wwwusername, $wwwsql_password) or die("Err");  
$dbwww = @mysql_select_db($wwwdb_name, $wwwconnection) or die("Could Not Select Database. www ");

Any ideas :?: Should I post this some other place :?:

Posted: Mon Jan 23, 2006 3:24 pm
by Christopher
Hard to tell. You might want to check the default port setting (MYSQL_TCP_PORT and mysql.default_port).