AceOfJames Posted March 12, 2016 Share Posted March 12, 2016 (edited) I am dabbling in php and I'm far from a pro. This simple database connect is baffling me and it should simply just work. This is the error I get. Can anyone suggest what I can do to fix this? Warning: mysql_connect(): Access denied for user 'therez_db'@'localhost' (using password: YES) in /home2/therez/public_html/rez/includes/mysql.class.php on line 128Database error 0:linkID == False. Connect failed.Warning: mysql_select_db() expects parameter 2 to be resource, boolean given in /home2/rez/public_html/therez/includes/mysql.class.php on line 131Database error 0:Cannot use database 'therez_db'. The username and password are both valid! Thank you in advance! James Edited March 12, 2016 by AceOfJames Quote Link to comment Share on other sites More sharing options...
benanamen Posted March 12, 2016 Share Posted March 12, 2016 (edited) Stop what your doing right now! That code is obsolete and has been completely removed from Php. You need to be using PDO with prepared statements. Tutorial here: https://phpdelusions.net/pdo Edited March 12, 2016 by benanamen Quote Link to comment Share on other sites More sharing options...
AceOfJames Posted March 13, 2016 Author Share Posted March 13, 2016 This works on same server but different domain. It however spits out this error when reinstalled on second domain. Anyone? Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 13, 2016 Share Posted March 13, 2016 are you sure of the database server hostname for the new domain? it may in fact be different from any previous domain. are you sure of the database username and database name? a lot of web hosting requires the hosting account name as part of the database username. after you created the database username/password, did you assign that database username privileges to the database you are trying to use? Quote Link to comment Share on other sites More sharing options...
AceOfJames Posted March 13, 2016 Author Share Posted March 13, 2016 All good points Mac. Those bases are all covered though. I created the user with all the privileges and the db and db user are both valid. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted March 13, 2016 Share Posted March 13, 2016 what tool/software are you using to assign privileges to the database? you may need to explicitly flush the privileges to get them to take effect. another possibility is if you have a typo or some white-space as part of the value(s) in the php code. Quote Link to comment 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.