Jump to content

Recommended Posts

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'nyhungry_builder'@'localhost' (using password: YES) in /home3/nyhungry/public_html/musicmakerstore/storescript/connect_to_mysql.php on line 19

could not connect to mysql

 

 

I am getting this error from the code below how come?

 

<! <?php 

// Place db host name. Sometimes "localhost" but 
// sometimes looks like this: >>      ???mysql??.someserver.net
$db_host = "localhost";
// Place the username for the MySQL database here
$db_username = "nyhungry_builder"; 
// Place the password for the MySQL database here
$db_pass = "blablabla"; 
// Place the name for the MySQL database here
$db_name = "nyhungry_musicbeatmaker";

// Run the actual connection here 
mysql_connect("$db_host","$db_username","$db_pass") or die ("could not connect to mysql");
mysql_select_db("$db_name") or die ("no database");             
?>

 

 

I am working on a cpanel kind of host and you know how the databases are setup like blablab_databasename etc..

 

 

What is going on here i have check the database name, the table, password and the host thousands of times and nothing..

 

Help

Link to comment
https://forums.phpfreaks.com/topic/230882-warning-mysql_connect/
Share on other sites

If you created the account in cpanel, did you then assign the account to the database?

 

After "MySQL add users", make sure you go down the page, and "Add users to Database".

 

Then make sure that your database name and the user name is listed in the "current database" table, around the middle of the page.

That error is telling you that either the username is incorrect or the password is. Make doubly sure that the case of the strings are correct, since everything is case sensitive.

 

I've been using MySql with cPanel for years and I never have a problem with it.

 

Ken

cPanel and addon mysql user's can be a pain..

 

To test it better I recommend using the default username and password for the cpanel account.

 

What is the cpanel account username and password?

 

The one I use to login into my host account?

 

 

 

That error is telling you that either the username is incorrect or the password is. Make doubly sure that the case of the strings are correct, since everything is case sensitive.

 

I've been using MySql with cPanel for years and I never have a problem with it.

 

Ken

 

Ken in the code provided above what is the username and password that goes inside the code? the host username and password or the database username and password?

 

 

Final question adding or not privileges when adding and creating a user to a database will have some type of impact on this error?

Now at list it goes into the file below else statement. the file below is called create_admin_table.php this file is suppose to create a database table. It will create a table if I type url www.radio.com/storescript/create_admin_table.php in firefox address bar.

 

But still it is displaying the message in the else statement.

 

" <! CRITICAL ERROR: admin table has not been created  "

 

 

 

 

 <?php  
// Connect to the file above here  
require "connect_to_mysql.php"; 

$sqlCommand = "CREATE TABLE admin( 
               id int(11) NOT NULL auto_increment,
               username varchar(24) NOT NULL,
		   password varchar(24) NOT NULL,
		   last_log_date date NOT NULL,
		   PRIMARY KEY(id)
		   UNIQUE KEY username(username)
		   )";
if (mysql_query($sqlCommand))
{
echo "Your admin table has been created successfully!";

}  

else {
echo "CRITICAL ERROR: admin table has not been created";
}
  
?>

 

 

 

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.