Thanks for the recommendation Sonic Waffle. I'm still encountering issues when attempting to connect to my client MySQL from my website.
First let me apologize in advance for the mass amount of text. I walk you through my process step-by-step just to make sure I have not done anything incorrectly or missed anything.
In the MySQL command-line client (on the computer hosting the server) I have:
1) Used
Code:
CREATE USER 'root'@'ip_address_of_my_website' IDENTIFIED BY 'password';
2) Used
Code:
GRANT ALL ON *.* TO 'root'@'ip_address_of_my_website' IDENTIFIED BY 'password';
To enable my website to remotely access my client MySQL server using username root and password password
The ip_address_of_my_website was determined here by entering my website's url into the url field at the bottom. So my first question is: is this the right IP address for my website?
Once that was complete I forwarded port 3306 onto my router using both UDP and TCP connections. Interestingly, many of the online port-checkers claim that port 3306 is still closed. However, the PFPortChecker application I downloaded from here claims that the port is open. From what I gathered, I think the PFPortChecker is more accurate than the online checkers because they look for an "application listening for the port test on your computer, and then assume that the test was OK simply because they were able to connect to your computer." Therefore I think it is safe to assume that port 3306 is open on my router, no?
Once the port-forwarding and MySQL remote-access configurations were complete, I began scripting my PHP files to process the html forms for account creating and logging in. In this segment I will use my check_logon.php as an example.. Here is the segment of relevance of the check_logon.php file in my site's FTP directory:
PHP Code:
<?php
$host="my_remote_ip"; // Host name
$username="root"; // Mysql username
$password="password"; // Mysql password
$db_name="logon_database"; // Database name
$tbl_name="accounts"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
/* ... */
?>
Where my_remote_ip is the remote IP address of my computer, retrieved from here, root is the same username that I configured my client's MySQL server remote-access for my website (GRANT and CREATE USER) with, password is the name of the password that I configured my client's MySQL server remote-access for my website with, logon_database is logon the database within my client MySQL server and accounts is the table within the logon database of my client MySQL server that contains the account information.
My second question is am I using the correct IP-address for my client MySQL server? Should it be the remote IP address of my computer (the one I am currently using), the IP-address I forwarded port 3306 with (my static IP) or some other IP address?
However, upon logging in to my site, I get a "cannot connect" message, indicating that the website could not connect to the clien MySQL server and executed the die() function. Can anyone provide me with any insight as to what I may be doing incorrectly or missing?