ken902 Posted December 27, 2009 Share Posted December 27, 2009 I am sure a simple explanation to this Error for a seasoned PHP prof. Have set up dbase, user and password ---all correct in config.php Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: NO) in /home/discover/public_html/photoarena/includes/connect_db.php on line 11 ERROR in 11 at /home/discover/public_html/photoarena/includes/connect_db.php http://www.discoversecretsfor.com/photoarena/ Any help here would be most grateful. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/186435-warning-mysql_connect-functionmysql-connect/ Share on other sites More sharing options...
oni-kun Posted December 27, 2009 Share Posted December 27, 2009 It says you're not using a password.. Well, try rewriting it with this correct code: <?php $dbhost = 'localhost'; $dbuser = 'root'; $dbpass = 'password'; $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql'); if (!$conn) { die ('SQL connection failed'); } $dbname = 'databasenamehere'; mysql_select_db($dbname); ?> Of course, filling in the values with your own. If you're using software you downloaded, there should be a guide! Quote Link to comment https://forums.phpfreaks.com/topic/186435-warning-mysql_connect-functionmysql-connect/#findComment-984521 Share on other sites More sharing options...
PFMaBiSmAd Posted December 27, 2009 Share Posted December 27, 2009 If you are doing this on a live web server, the username and password would most assuredly NOT be 'root' and with no password. The hostname may or may not be 'localhost'. The hostname you use will be specified by your web host for your account. The hostname can usually be found within your control panel somewhere on the same page where you created your database and then created the username, and password to access that database. Your web host may in fact have already created a database (i.e. he only gives you one) and you would just create and assign a username and password to access that database. Quote Link to comment https://forums.phpfreaks.com/topic/186435-warning-mysql_connect-functionmysql-connect/#findComment-984565 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.