Jump to content

"Unable to select the specified database"


cesare88

Recommended Posts

Hello,

 

I inherited a site from a previous developer, and we are setting up an automatic upload for my client's products. Last night, all of a sudden after uploading a former version of their site and a backup db, I began getting this error message:

 

A Database Error Occurred

Unable to select the specified database: ***_DB

Filename: /home/***/public_html/libraries/MX/Loader.php

Line Number: 104

 

The "Libraries" directory does not exist, and it does not exist on the old server (their old hosting account is still active). I have been looking online, and it hasn't really gotten me anywhere. Can anyone help me troubleshoot what could be causing this?

 

Thank you in advance for your help; your time and attention is very much appreciated. 

Link to comment
Share on other sites

you can use your database library's error function to find out why the database selection isn't working. which database library is the code using? mysql, mysqli, pdo, ...?

 

it's either doesn't exist by the exact name being used in the code or there's a permission problem or a database connection problem.

Link to comment
Share on other sites

Thank you both very much for your response!

 

@mac_gyver: I am using MySQL version 5.0.96-community-log. I am very new to db management, and I am not sure how to use the library's error function. What would I put inside the square brackets in this situation? 

string mysql_error ( [ ?? ] )

@requinix: I am not very up to date on db security. Are you insinuating that the file being called (in the /libraries/ directory) could be malicious?

Link to comment
Share on other sites

But the file "Loader.php" exists, right?

 

So, what is the code at the line 104 or 105? 

 

PS: Also, to get a proper dir path to this file you would use the __DIR__  function (put it on the top of this file) :

 

Loader.php

echo __DIR__;
Edited by jazzman1
Link to comment
Share on other sites

 

But the file "Loader.php" exists, right?

 

So, what is the code at the line 104 or 105? 

 

PS: Also, to get a proper dir path to this file you would use the __DIR__  function (put it on the top of this file) :

 

Loader.php

echo __DIR__;

no, the loader file does not exist in the ftp directory (according to filezilla). 

Link to comment
Share on other sites

That is why I am so confused. I have no idea where to begin looking because the file does not appear to exist. Is it possible that this is a hidden directory? If I can't find the file using Filezilla, is there another way I might be able to find it?

Link to comment
Share on other sites

Find the file, which itself contains strings like these (if we are using the mysql library, of course):

$conn = mysql_connect('old_db_server','old_db_user','old_db_pass');

$db_name = mysql_select_db('db_name');

and change to:

$conn = mysql_connect('new_db_server','new_db_user','new_db_pass') or die(mysql_error());

$db_name = mysql_select_db('new_db_name') or die(mysql_error());

Also, if this db file is included inside other one, make sure that the path to this file is set properly!

 

That's all you have to do for now.

Link to comment
Share on other sites

there are two possibilities -

 

1) the information from the error reporting logic is correct and there is a path/file that is somehow hidden.

 

2) the information from the error reporting logic is bogus (hard-coded copy/pasted path/file information) and the error is occurring somewhere else.

 

you apparently have a set of files present in your off-line copy, that you recently uploaded to the server at the point this problem started. did any errors occur while you were FTPing the files (i.e. you actually did upload and replace all the files on the server)? i would recommend that you zip all the files (less your database connection credentials) and a attach them to a post in this thread.

Link to comment
Share on other sites

there are two possibilities -

 

1) the information from the error reporting logic is correct and there is a path/file that is somehow hidden.

 

2) the information from the error reporting logic is bogus (hard-coded copy/pasted path/file information) and the error is occurring somewhere else.

 

@mac_gyver, every hidden directory or file is prefixed by a "." period symbol on the unix systems, so I completely exclude the possibility of server side error here.

My best guess, without seeing any code is that he's trying to run a different database config file from other domain or sub-domain located on the same web root.

Edited by jazzman1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.