I've got a mySQL database I've been working with as my localhost for several months now, no connection problems. I'm at the point however, where I need to connect to the database from another site / different IP address.
I'm playing around in the PayPal sandbox, and I'm running an instant payment notification php script before the user exits. The included connection file looks like this:
Expand|Select|Wrap|Line Numbers
- <?php
- $hostname_TFATP = 'mywebsite.com'; // (used to be localhost)
- $database_TFATP = 'mydatabase_TFATP';
- $username_TFATP = 'mydatabase_danny';
- $password_TFATP = 'christmas123';
- $TFATP = mysql_pconnect($hostname_TFATP, $username_TFATP, $password_TFATP) or trigger_error(mysql_error(),E_USER_ERROR);
- ?>
PHP Warning: mysql_pconnect() [<a href='function.mysql-pconnect'>function.mysql-pconnect</a>]: Access denied for user 'mydatabase_danny'@'gator306.hostgator.com' (using password: YES) in /home/mydatabase/public_html/Connections/TFATP_paypal.php on line 9
So I read up on this. I find out I need to allow the host access to my database, so I go into the ACCESS HOSTS portion of the mySQL account maintenance and I add the following address: 66.135.197.% All PayPal addresses start with 66.135.197 and I throw the wild card in at the end. But I still get the error.
Someone suggested I make sure there was no 'bind' address in my mySQL config file, but I couldn't find that file. So I called HostGator (my host) and asked them about it. They assured me they don't use binds, so that was a dead end.
For giggles I decided to temporarily allow ALL addresses access to my database by entering all wildcards of %.%.%.% under the access hosts. When I ran through the process this time, I got a different error:
[20-Dec-2007 11:38:21] PHP Fatal error: Call to undefined function: dbquery() in /home/mydatabase/public_html/include/paypal/ipn.php on line 27
The lines leading up to line 27 of that script look like this:
Expand|Select|Wrap|Line Numbers
- <?php
- line 20 require_once('../../Connections/TFATP_paypal.php');
- line 21
- line 22 // check that the invoice has not been previously processed
- line 23 $sql = "SELECT status
- line 24 FROM tbl_order
- line 25 WHERE order_id = {$_POST['invoice']}";
- line 26
- line 27 $result = dbQuery($sql);
Does this mean it got past the connect part and blew up on the dbquery? Can I safely assume it connected?
Can anyone offer up any other solution to my connection problem, other than wildcarding the entire world access to my database? Because that's just not gonna fly.
Thanks in advance!