PDA

View Full Version : Can't connect to new SQL database



spenland
03-06-2006, 07:24 PM
Hi guys, I just signed up with a new server and I'm having trouble connecting to the database.

My current server is a windows based server and my new server is Linux. I want to fully test the database on the new server before I change the DNS.

Here is the config.php file that I use for a few pages:

CONFIG.PHP
<?php

$xxxConfig_dbhost = 'mysql.mywebsite.com';
$xxxConfig_dbusername = 'sql@mywebsite.com';
$xxxConfig_dbpasswd = 'password';
$xxxConfig_database_name = 'database';

?>

And here is the db.php file:

DB.PHP
<?
/* Database Information - Required!! */
/* -- Configure the Variables Below --*/

require_once("config.php");

/* Database Stuff, do not modify below this line */

$connection = mysql_pconnect("$xxxConfig_dbhost","$xxxConfig_dbusername","$xxxConfig_dbpasswd")
or die ("Couldn't connect to server.");

$db = mysql_select_db("$xxxConfig_database_name", $connection)
or die("Couldn't select database.");
?>

Of course I changed the real values but the syntax is the same.

Now the new server that I'm trying to connect to is a Fedora Linux server. I tried to use the same code above to connect to the server using just the IP address because I want to fully test the site before I change the DNS. Here it is

CONFIG.PHP (NEW)
<?php

$xxxConfig_dbhost = 'mysql.00.11.22.333';
$xxxConfig_dbusername = 'sql';
$xxxConfig_dbpasswd = 'password';
$xxxConfig_database_name = 'database';

?>

The only real difference here besides changing the IP address is that the new username doesn't have the @mywebsite.com after it. I assume this is a limitation of Linux.

Am I doing this correctly? I feel like I've tried everything. Is it possible to connect to a database by IP only?

I appreciate any help

thanks

Faglork
03-07-2006, 05:50 AM
The only real difference here besides changing the IP address is that the new username doesn't have the @mywebsite.com after it. I assume this is a limitation of Linux.


No. If at all, it would be a limitation of mysql.


Am I doing this correctly? I feel like I've tried everything. Is it possible to connect to a database by IP only?


Try

$xxxConfig_dbhost = 'localhost';

Apart from that: Don't you get any error messages? Did you check server lof files?

hth,
faglork

spenland
03-07-2006, 11:48 AM
Thanks faglork that seemed to do the trick. I owe you a beer next time I'm in Deutschland!

Faglork
03-27-2006, 05:52 AM
Well, I live in the area with the highest density of breweries in the world, so we'd have plenty of choice ;-)

Cheers,
faglork