cesare88 Posted August 9, 2013 Share Posted August 9, 2013 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 OccurredUnable 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. Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/ Share on other sites More sharing options...
mac_gyver Posted August 9, 2013 Share Posted August 9, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444204 Share on other sites More sharing options...
requinix Posted August 9, 2013 Share Posted August 9, 2013 It's very likely that file does exist, even if only on the server and not in the files you were trying to upload. Does it look malicious? Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444205 Share on other sites More sharing options...
cesare88 Posted August 9, 2013 Author Share Posted August 9, 2013 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? Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444210 Share on other sites More sharing options...
jazzman1 Posted August 9, 2013 Share Posted August 9, 2013 (edited) 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 August 9, 2013 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444221 Share on other sites More sharing options...
cesare88 Posted August 9, 2013 Author Share Posted August 9, 2013 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). Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444228 Share on other sites More sharing options...
jazzman1 Posted August 9, 2013 Share Posted August 9, 2013 Well, what's the name of the file generating that error message, above? Or this is from the server side error log file? Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444231 Share on other sites More sharing options...
cesare88 Posted August 9, 2013 Author Share Posted August 9, 2013 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? Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444235 Share on other sites More sharing options...
jazzman1 Posted August 9, 2013 Share Posted August 9, 2013 You should provide us the code of the file dealing with DB server. Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444243 Share on other sites More sharing options...
cesare88 Posted August 9, 2013 Author Share Posted August 9, 2013 How do I determine that? Is there a piece of code I can use to search through dreamweaver to find the file? Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444245 Share on other sites More sharing options...
jazzman1 Posted August 9, 2013 Share Posted August 9, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444261 Share on other sites More sharing options...
mac_gyver Posted August 10, 2013 Share Posted August 10, 2013 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. Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444264 Share on other sites More sharing options...
jazzman1 Posted August 10, 2013 Share Posted August 10, 2013 (edited) 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 August 10, 2013 by jazzman1 Quote Link to comment https://forums.phpfreaks.com/topic/281004-unable-to-select-the-specified-database/#findComment-1444266 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.