dlyles Posted November 24, 2006 Share Posted November 24, 2006 Let me say that I am an extreme newbie. I usually program using ASP, however I'm on a Linux server at work now, so...I'm having a basic problem connecting to the data. The password I'm using connects me to phpmyadmin just fine. However, trying to connect using the below code gives me an access denied error.$user="root";$password="****";$dbh=mysql_connect("localhost", $user, $password);I stripped everything so I could get to the root of the problem. What is the root of the problem? Link to comment https://forums.phpfreaks.com/topic/28343-very-basic-connection-question-very-newbie/ Share on other sites More sharing options...
Jenk Posted November 24, 2006 Share Posted November 24, 2006 change your connection line to:[code=php:0]$dbh=mysql_connect("localhost", $user, $password) or die(mysql_error());[/code]and it will display the error message. Link to comment https://forums.phpfreaks.com/topic/28343-very-basic-connection-question-very-newbie/#findComment-129640 Share on other sites More sharing options...
dlyles Posted November 24, 2006 Author Share Posted November 24, 2006 Sorry, I should've posted that earlier.Access denied for user 'root'@'localhost' (using password: YES)But, like I said, I can connect to phpmyadmin using the same username and password. Link to comment https://forums.phpfreaks.com/topic/28343-very-basic-connection-question-very-newbie/#findComment-129648 Share on other sites More sharing options...
c_shelswell Posted November 24, 2006 Share Posted November 24, 2006 try omiting the password when i log on to mysql at home its not set up to have a password for the root user. I was getting the same error until i just logged on as root. Link to comment https://forums.phpfreaks.com/topic/28343-very-basic-connection-question-very-newbie/#findComment-129652 Share on other sites More sharing options...
dlyles Posted November 24, 2006 Author Share Posted November 24, 2006 I did that also and got the same error message (of course with the exception of "USING PASSWORD..." Link to comment https://forums.phpfreaks.com/topic/28343-very-basic-connection-question-very-newbie/#findComment-129659 Share on other sites More sharing options...
marcus Posted November 24, 2006 Share Posted November 24, 2006 Connect to the database itself.[code]$dbh = myaql_connect(host,dbuser,dbpass);$db = mysql_select_db(dbname,$dbh);[/code] Link to comment https://forums.phpfreaks.com/topic/28343-very-basic-connection-question-very-newbie/#findComment-129670 Share on other sites More sharing options...
dlyles Posted November 24, 2006 Author Share Posted November 24, 2006 Tried that too :-\ Link to comment https://forums.phpfreaks.com/topic/28343-very-basic-connection-question-very-newbie/#findComment-129675 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.