DH hosted PHP Can't Access DH Hosted MySQL

software development

#1

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’
Code:
//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!

Thanks!
Tom


#2

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 %.


#3

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’@‘173.236.128.0/255.255.128.0’ to database ‘tablename’

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

==============


#4

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.


#5

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’@‘173.236.128.0/255.255.128.0’ to database ‘databasename’

===========


#6

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!

Tom


#7

It’s always the simple things!