Jump to content
xisto Community
Sign in to follow this  
kgd2006

Problem With MySQL Not Being Able To Connect Anyone know the reason for this error...

Recommended Posts

Hello everyone,

Im currently having a problem with mySQL, I wrote a PHP login script that doesnt seem to be working for some reason. I created a database and everything looks correct, is this a server issue or is the issue related to my script? But anyway this is my error, hope someone can help Ive tried to search forum for answer but none of the posts seems to answer my question:

Warning: mysql_connect(): Host 'gamma.xisto.com' is not allowed to connect to this MySQL server in /home/hp2001/public_html/ucscKGD/checklogin.php on line 10cannot connect


I set the $host=Xisto.com, would it be $host=gamma, which is the server my site is at. I tried both and still recieve error...Hope someone can help me...

Share this post


Link to post
Share on other sites

Nope - your host should be yoursubdomain.astahost.com. Maybe that's where it's going wrong - it's trying to connect to the MySQL DB's of the main Xisto.com domain.

 

Try adding in your own subdomain before that and write back if it works. :lol:

Share this post


Link to post
Share on other sites

Nope doesnt look like its working...hmmm cant be my code, cause its the same code I used at another free hosting server, just that I have to modify the correct hosting variable...hmmm...but this is wut i get when I change the $host="hp2001.astahost.com"

Warning: mysql_connect(): Host 'gamma.xisto.com' is blocked because of many connection errors. Unblock with 'mysqladmin flush-hosts' in /home/hp2001/public_html/ucscKGD/checklogin.php on line 10cannot connect


from the search results I checked on the forum people talked about overloads of the mySQL server, could that be it...the error doesnt seem to make sense if its a mySWL server overload problem...

Share this post


Link to post
Share on other sites

I don't think it's an overload problem - coz my site (Antilost) is loading fine, and it's hosted on Gamma. Can you paste the connection part of your script here ? That might give me an idea..

 

However - on second thoughts, Host 'gamma.xisto.com' is blocked because of many connection errors. - that statement does indicate a temporary lockup owing to too many persistent connections.

 

Lets wait up for sometime and see if it gets fixed. Usually such overloads are auto-resolved within 15 minutes or maybe a bit more sometimes.

Share this post


Link to post
Share on other sites

Hmm...wonder whats wrong, well heres my script:

<?phpob_start();$host="hp2001.astahost.com"; // Host name $username="hp2001"; // Mysql username $password="********"; // Mysql password $db_name="hp2001_ucscKGD"; // Database name $tbl_name="members"; // Table name // Connect to server and select database.mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB");// Define $myusername and $mypassword $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";$result=mysql_query($sql);// Mysql_num_row is counting table row$count=mysql_num_rows($result);// If result matched $myusername and $mypassword, table row must be 1 rowif($count==1){// Register $myusername and redirect to file "members.php"session_register("myusername");header("location:members.php");}else {header("location:incorrectUP.php");}ob_end_flush();?>

Share this post


Link to post
Share on other sites

The code seems absolutely fine except for one little mistake..

$host="hp2001.astahost.com"; // Host name$username="hp2001"; // Mysql username$password="********"; // Mysql password$db_name="hp2001_ucscKGD"; // Database name$tbl_name="members"; // Table name 

Notice that for $db_name - you've prefixed the database name with hp2001 - which is your cPanel username. Similarly, for $username - you'll have to prefix your MySQL DB username, with another hp2001. So it should be $username = "hp2001_hp2001"

 

By default whenever you create a new MySQL DB and a username for it, they're both prefixed with your cPanel username.

 

Try that and let me know - although, if it was a problem with the username, the error message should have said so. Seems like it's not connecting in the first place. Still give it a try and let me know.

Share this post


Link to post
Share on other sites

I tried wut u suggested and it still has the same problem, and is there a way to unblock? I can seem to find the phpadmin to flush the block...I guess Ill just retry tomrrow when its free from the block...

Share this post


Link to post
Share on other sites

Try "localhost" for the host name it works fine for me

$host="hp2001.astahost.com"; // Host name$username="hp2001"; // Mysql username
$password="********"; // Mysql password
$db_name="hp2001_ucscKGD"; // Database name
$tbl_name="members"; // Table name

change it to
$host="localhost"; // Host name$username="hp2001"; // Mysql username (make this your username that you login to cPanel with)$password="********"; // Mysql password(make this the password you login to Xisto cPanel with)$db_name="hp2001_ucscKGD"; // Database name$tbl_name="members"; // Table name

Share this post


Link to post
Share on other sites

but would localhost...be if you are hosting it privately on your machine with a setup apache server, cause I use localhost as the value when I am testing php scripts on my computer. For webhosts it should be the hostname of the server...I cant seem to get it working, I can get this script working successfully at another freehosting site but how come Im gettin problems here? I will try put localhost, im up to try anything right now...haha...EDIT>>WOW...HOUDINI...YOU ARE THE MAN!!! Haha, it worked...odd tho, how the hostname would be localhost, I would think the name be the servers hostname...

Edited by kgd2006 (see edit history)

Share this post


Link to post
Share on other sites

That is because normally MySQL runs as localhost, there is one host that I must connect to as mysql not localhost. Most of the time localhost is fine it is the username and password that matter to the MySQL server.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.