Forum Moderators: coopster

Message Too Old, No Replies

Problem selecting a MYSQL database

Web server upgraded and now cannot connect to database

         

nubbin

10:00 pm on Aug 18, 2004 (gmt 0)

10+ Year Member



Hi,

The problem is I can no longer select my MYSQL database. Consequently the dynamic pages of my web site no longer work.

The way I do it is from a PHP script.
Step 1. Connect to local host by including a php script to make the connection:
include ('../../connect.php')

Step 2. Select the database to work with:
$db1='****'
$db = @mysql_select_db($db1);
if (!$db) { // if value in variable is false (!)
die('Could not select MySQL database, the server returned the error: '.mysql_error());
}

Step 2 is failing with the 'Could not select MYSQL...'error, but always worked until last night. I believe my web server was upgraded by my hosting provider last night

I have discovered that if I cut and paste the lines of code in step 1's connect.php into the same script as the code in Step 2, then I can connect to the MYSQL database ok. Obviously I do not want to use this workaround as it means I would have to paste the connection scipt into a lot of web pages, and this is also less secure as my connection password can be seen more easily

Does anyone know how I fix this problem

Thanks
Peter

08/18/04 4:45:46 PM
==========

coopster

10:24 pm on Aug 18, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



The first thing I would check would be the path to that include file. Try turning on your error_reporting first to see if that gives you any clues as to what is going on...
error_reporting(E_ALL); 
// Now, if there is a path problem, you'll get an error message here...
include ('../../connect.php')
Also, you never told us what the mysql error was...?

nubbin

3:45 am on Aug 19, 2004 (gmt 0)

10+ Year Member



Hi Coopster,
Thanks, you were right. I was on the verge of concluding that when I got your reply. When my host upgraded my server they changed the directory structure so my relative paths didn't work any more.

Thanks for pointing me in the right direction

Peter