Jump to content

Warning: mysql_connect() [function.mysql-connect]: ????


ken902

Recommended Posts

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

 

 

 

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.