DH hosted PHP Can't Access DH Hosted MySQL

software development


Hi all: While I’ve been programming for quite a while, this is my first dive into the world of PHP and web based programming (I’ve been a local client-server guy on the Microsoft platform).

My problem relates to allowing a pre-defined user in a DH hosted MySQL DB to access the DB from a DH hosed PHP script.

The following is the error I am receiving and the code:

Error: Access denied for user ‘myuser’@’%’ to database 'mydatabase’
//Connect to the Database
$con = mysql_connect(‘my.database.host’, ‘myuser’, ‘mypassword’) ;
if (!con){
die ('Can’t execute mysql_connect : ’ . mysql_error());

// failing above

$db_selected = mysql_select_db(‘mydatabase’, $con);
if (!$db_selected) {
die ('Can’t use mysql_select_db : ’ . mysql_error());

In the “allowable hosts” for this user, I am specifying %

Weird thing is, I can connect to the table and DB using a third party SQL tool on the desktop. I would think speaking internally between DH servers would be easier!

Oh well. Any help would be appreciated!



If you require desktop access, add your external IP rather than a blanket %.

If you require desktop access, add your external IP rather than a blanket %.


Hey! Thanks for the response. I’ve made the change and I now have a variation on the error message I listed originally. New response:

Access denied for user ‘username’@‘’ to database ‘tablename’

I assume that this IP points to the DH web server.



If that’s really what it’s saying, there’s something wrong with your database connection info. It should be showing the name of the database there, not the name of a table in that database.


Sorry, my mistake in parsing out the sensitive info in the error message. The actual error message is as you suspected:

Access denied for user ‘username’@‘’ to database ‘databasename’



Well, your response got me to thinking and I took another look at my code. I actual DID put the tablename instead of the database name.

Problem solved, thanks very much!



It’s always the simple things!