running mysql on godaddy server - can't connect to my db

phillystyle123
phillystyle123 used Ask the Experts™
on
MySQL and PHP are both running on my godaddy windows server. I've successfully installed the MySQL DB and I can run php on the server. HOWEVER when I try to connect a page to the MySQL db - no dice - this is what my connection file looks like:

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_mbb = "xxx.hostedresource.com";
$database_mbb = "xxxwebsitedb";
$username_mbb = "xxxwebsitedb";
$password_mbb = "xxxx";
$mbb = mysql_pconnect($hostname_mbb, $username_mbb, $password_mbb) or trigger_error(mysql_error(),E_USER_ERROR);
?>

and this is how i'm connecting:

<?php require_once('Connections/mbb.php'); ?>

now, i built this site on a linux server and have no problems with the connection or any other bugs -
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Fixer of Problems
Most Valuable Expert 2014
Commented:
This is what I'm using on my Godaddy Windows hosting and it works fine.  It's not in a separate file though.
//mysql_connect('localhost', 'mysql_user', 'mysql_password');
$dbh = mysql_pconnect($dbhost, $dbuser, $dbpass);
mysql_select_db($dbname);

Open in new window

Author

Commented:
This is what I had to do to get my MySQL connection to work on my godaddy Windows server:

1. I found this godaddy help article and created a test page with the connection info on the same page (not a separate file):

http://help.godaddy.com/topic/67/article/3351

2. After doing this, I got this error:

Client does not support authentication protocol requested by server; consider upgrading MySQL client

So, I logged on to phpMyAdmin and ran this command:
SET PASSWORD FOR user@localhost = OLD_PASSWORD('password');
The reasons for doing so can be found here:
http://geekswithblogs.net/TimH/archive/2005/10/31/58591.aspx

3. Then - since set up an external file originally to handle my connection - and it no longer worked when I migrated to godaddy - I made adjustments and this is what my external file looks like (that works with godaddy):

<?php
$hostname="xxx.hostedresource.com";
$username="myusername";
$password="mypassword";
$database_mbb="mydatabase";

$con = mysql_connect($hostname,$username, $password) or die ("<html><script language='JavaScript'>alert('Unable to connect to database! Please try again later.'),history.go(-1)</script></html>");
?>

4. then in my php file I put this at the top:

<?php require_once('Connections/con.php'); ?>
<?php
mysql_select_db($database_con, $con);





Author

Commented:
See my comment below for the full solution - but this code works to make the connection in godaddy - it just took me an extra step and then i created an external file
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Interesting.  the only time I've seen that error message is when either the PHP MySQL driver or the MySQL server were really new versions that weren't compatible with an older one.  My program runs from the Godaddy server and from my own IIS5.0 server to connnect to the MySQL server on Godaddy.  I set my database up for external access.

The only real difference between my code and the code above is the 'die' part after the connect statement.  And I'm using 'mysql_pconnect' (persistent) where you're using 'mysql_connect'.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial