PDA

View Full Version : DATABASE CONNECTION Urgent PLZ



manhal
04-24-2009, 01:29 PM
i have a php site in my computer (localhost) working without any problem.I use this code to connect to database MYsql
<?php
$dbh=mysql_connect ("servername", "usrnam", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("dbname");
?>
and also working under this code
<?php
$dbh=mysql_connect ("servername", "usrname", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("dbname");
?>
when i upload to my site iam facing this error in mysql connection and when i use PHPMYADMIN i can login to mysql without any problem by using the same username and pass .
<?php
$dbh=mysql_connect ("servername", "usrname", "pass") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("dbname");
?>
Warning: mysql_query() [function.mysql-query]: Access denied for user 'vhostswww'@'localhost' (using password: NO).

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established.
Warning: mysql_result(): supplied argument is not a valid MySQL result resource.

felgall
04-24-2009, 02:52 PM
do you have servername set to "localhost"?

Do you have your bluehost account name and an underscore on the front of the username and database name fields?

If tnot then that is why it isn't working.