Pages

Wednesday, March 6, 2013

Error while connecting to the mysql databse with php whereas username and password are correct

Some time you face this problem specially new programmers while connecting to the mysql database that they are not able to connect it to the database on their hosting server whereas their username and password they have created are correct. So what the thing they missed out?

Its the hosting service prefix

whenever you are in any hosting serivice its having a username prefix for example

user login for hosting service bibo123 and password *******

so whenevr you create a database and new user to that hosting account it will prefic the bibo123_ on that database name and username too. So if you are having a database name student it will prefix the bibo123_ to it and it will become bibo123_student. so as it will do with the username also. for description their is an example below to connect to mysql database

hosting login: bibo123_
username you created: jinah
password: pikachu


$username = bibo123_jinah;
$password = bibo123_password
mysql_connect("localhost", $username, $password) or die(mysql_error());
echo "Connected to MySQL
";
try it.



posted by honeyonsys

No comments:

About Me

Hi,My name is Harish Kumar.I am a web developer by profession.I am working in the same field since 2008. About my skills i am proficient in HTML,CSS,JAVASCRIPT/JQUERY/ ANGULAR,PHP,MYSQL,APACHE,LINUXAJAX, REST,etc...