You are here:  » Database on one URL and server, web site on another

Support Forum



Database on one URL and server, web site on another

Submitted by Mark on Sun, 2009-05-24 13:46 in

Hi Dave,

How do you put the database on one URL and server, while the web site is on another? Can this be done from config.php?

Cheers
Mark

Submitted by support on Mon, 2009-05-25 10:43

Hi Mark,

PHP needs to access the database natively, but the database can still be on a different server - and in my shared hosting environments it often is. Typically, where MySQL is on the same server you would have in config.php:

  $config_databaseServer = "localhost";

...and when it's on a remote computer, something like:

  $config_databaseServer = "mysql1234.example.com";

So that would be all you need to do, but bear in mind that any firewalls etc. would have to be configured to allow inbound access to the remote server on the default MySQL port (3306), and also MySQL would have to be configured to listen on that port also instead of only accepting local connections...

Cheers,
David.

Submitted by Mark on Sun, 2009-05-31 13:23

Hello. Thanks.
We have tried the above, and we are getting the following errors:

Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/server5/public_html/partnersite-cheapest-bargain.com/includes/database.php on line 17

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/server5/public_html/partnersite-cheapest-bargain.com/includes/database.php on line 21

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/server5/public_html/partnersite-cheapest-bargain.com/includes/database.php on line 26

Here is what our config file says (I've taken out the password):

<?php
  ini_set
('memory_limit','128M');
  
set_time_limit(36000);
  
$config_title "Cheapest Bargain [Remote Mode]";
  
$config_charset "utf-8";
  
$config_baseHREF "/";
  
$config_useRewrite TRUE;
  
$config_useRelated true;
  
$config_useTracking true;
  
$config_useJavaScript false;
  
$config_useInteraction true;
  
$config_currencyHTML "&pound;";
  
$config_resultsPerPage 10;
  
$config_databaseServer "cheapest_cbcouk.cheapest-bargain.org.uk";
  
$config_databaseUsername "cheapest_cbcouk";
  
$config_databasePassword "XXXXXXXXXXXX";
  
$config_databaseName "cheapest_cbcouk";
  
$config_databaseTablePrefix "";
?>

Can you see what the problem is?
Thanks,
Mark.

Submitted by support on Sun, 2009-05-31 14:55

Hi Mark,

With the new database settings in place, browse to setup.php - this will show you the result of testing each stage of the database connection (connection, authentication, SQL).

If this displays:

Checking database connection...FAIL

Then if you're sure that username and password are correct; the most likely cause is that the server at cheapest_cbcouk.cheapest-bargain.org.uk is not listening on the MySQL port (3306). Alternatively, if the server itself is listening, there could be firewall restrictions in place - check with your host if that is likely to be the case and they should be able to add an exception so that you are permitted to make this connection...

Cheers,
David.

Submitted by Mark on Wed, 2009-06-03 11:02

Thanks David - that works 100%