2
votes

Here is my connection code, I have made mysql database in 000webhost and I have also uploaded file in 000webhost but every time I am getting error like this " PHP Error Message

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'a1346052'@'10.1.1.39' (using password: YES) in /home/a1346052/public_html/connection.php on line 7

Free Web Hosting Could not connect database please help me on this, Thanks

<?php

$mysql_hostname = "mysql13.000webhost.com";

$mysql_user = "a1346052";

$mysql_password = "*****";

$mysql_database = "a1346052_simple";

$prefix = "";

   $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database");    
        mysql_select_db($mysql_database, $bd) or die("Could not select database");
?
1
Why you are still using mysql_connect() , It is deprecated, so please start usig mysqli or PDO ?Prafulla Kumar Sahu
And please remove password from your post.Prafulla Kumar Sahu
Well, it's either a wrong username, a wrong password or you are connecting from a host that is not allowed. The error message is pretty self explaining.Gerald Schneider
thanks a lot will look onto this :)S.S

1 Answers

0
votes

I dont think your username will only be that. There will certainly be a username along with the random number. Ex: a7238414_username. Try running following code and see what result it gives.

$dbhost = 'mysql13.000webhost.com';
   $dbuser = 'a7238414_username';
   $dbpass = '***';
   $conn = mysql_connect($dbhost, $dbuser, $dbpass);
   if(! $conn )
   {
     die('Could not connect: ' . mysql_error());
   }
   echo 'Connected successfully';
   mysql_close($conn);

Just a headsup, mysql is deprecated. You should start using mysqli or PDO :)