Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

psharp

macrumors member
Original poster
Feb 18, 2011
46
0
In an effort to learn something now that I'm done with school I decided to pick up PHP/MySQL. I use bluehost to host my portfolio but aside from that I feel like I'm not taking advantage of everything it has to offer. I ran into a nice snag when I tried to link PHP code to a database I created.

I followed these steps setting up the database: https://my.bluehost.com/cgi/help/6
Created a very simple 3 column table in the database.

Stripped down my code and eventually used the code they suggested

Code:
<?php

$dbh=mysql_connect ("localhost", "dbadmin", "********") 
     or die ('I cannot connect to the database.');
     mysql_select_db ("dbtest");
     echo "connected to the database";
?>

Yet I continue to get this error:
Code:
[12-Jul-2012 02:11:04] PHP Warning:  mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'dbadmin'@'localhost' (using password: YES) in /home6/sharpcgi/public_html/learning/action.php on line 3
And can't for the life of me figure out the problem. It would be great if someone had advice or a solution.
 
I was going to try and help. I started with php not to long ago and I also use bluehost but I have not created a db as of yet. But as I do get into db with bluehost was the problem on there end or a code bug on your end?
 
At a guess I'd say the username was incorrect, looking at the Bluehost document it looks like they auto-add a prefix to the username that your create so probably something like my account_dbadmin rather than just dbadmin ;)
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.