Php will not connect to old database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
slowpoke
Forum Newbie
Posts: 1
Joined: Mon Jan 23, 2006 1:06 pm
Location: Grand Rapids MI

Php will not connect to old database

Post 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 :?:
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Hard to tell. You might want to check the default port setting (MYSQL_TCP_PORT and mysql.default_port).
(#10850)
Post Reply