MySQL Error Access denied for user using password NO

user1380936 picture user1380936 · Jun 3, 2012 · Viewed 42k times · Source

I keep getting this error:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'mcabinet'@'localhost' (using password: NO) in /home/mcabinet/public_html/games/db_edit/airportmadness4.php on line 3

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/mcabinet/public_html/games/db_edit/airportmadness4.php on line 3
No Database found.

Here is my entire .php page:

<?php
include("../templates/base/template2/mysql_connect.php");




$gametitle = "Airport Madness TEST";
$gamedescription = "DESCRIPtion testing a description. LOL !";
$image1url = "http://website-gamesite.com/games/images/lhfdsjk.jpg";
$categorycode = "adv";
$gametitle2 = "airportmadnesstest";


mysql_query("INSERT INTO Games VALUES (null,'$gametitle','$gamedescription','$image1url','$categorycode','0','$gametitle2'") or die ("Error Inserting Values into the Games Table");

?>

Thanks! I am just beginning with PHP and MySQL.

EDIT: Here is the contents of the include file:

<?php

$db_host = "localhost";
$db_username = "mcabinet_admin";
$db_password = "4jf8ido9A";
$db_name = "mcabinet_games";

@mysql_connect($db_host,$db_username,$db_password) or die ('MySQL Not found // Could Not Connect.');
@mysql_select_db("$db_name") or die ("No Database found.");


?>

After editing with your tips, I still receive the error.

EDIT: I've made more changes. It is weird because when I get content from the database, the content is displayed fine, but with the errors still showing. And when I run the separate script, trying to add rows, it simply will not even connect.

Answer

Max Allan picture Max Allan · Jun 3, 2012

Try to move the include above the first query row! Like this

<?php
  include("../templates/base/template2/mysql_connect.php");
  $query = mysql_query("SELECT * FROM Games WHERE id = '1' "); 

To, make a MySQL-request you need to be connected first.