Ok, I'm really really stuck with this. I've tried everything to my knowledge to fix it, but I just can't. So please, can anyone here help me with this error:

Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on 'host-ip' (4) in /home/ashley/public_html/pw/inc/config.php on line 7

This is my PHP:

$dbconn = mysql_connect($dbhost, $dbuser, $dbpass);

I've tried everything, gone through 20 pages of Google, nothing. If anyone here can help me fix this, I will be eternally grateful.

Recommended Answers

Hi xapher19,

have you tried echoing the variables just before you try to connect, to make sure they are what you expect them to be?

echo "Host: " . $dbhost . "<br />User: " . $dbuser . "<br />Password: " . $dbpass;
Jump to Post

Have you tried contacting your webhost to see if they have had any problems (or updated MySQL)?

Jump to Post

All 6 Replies

Member Avatar

Hi xapher19,

have you tried echoing the variables just before you try to connect, to make sure they are what you expect them to be?

echo "Host: " . $dbhost . "<br />User: " . $dbuser . "<br />Password: " . $dbpass;

Yes, I've tried all of that. The thing is. This was working perfect 24 hours ago. I come back, and in my logs, at 4PM yesterday, the connection was severed and I haven't found the problem yet.

Member Avatar

Have you tried contacting your webhost to see if they have had any problems (or updated MySQL)?

All of the server are owned by us. Our database is a on our game server, the website on our web server. The database works fine on localhost, and our game is not affected. However, our web host is having problems connecting. Myself and my colleague have both successfully connected to the MySQL server through Navicat. This is what's confusing me so much.

Member Avatar

hmm, if no code or settings, like the users permissions, have been changed I'm not sure what the problem could be.

I don't think the problem is PHP related. The error message you are getting is just saying the script is trying to connect but can't.

Maybe try reposting in the MySQL forum to see if anyone there has any ideas?

I suppose I'll have to try figure it out =/ Thanks anyway

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.