Warning: mysql_query(): Access denied for user ‘admin’@’localhost’ (using password: NO)

It seems as though my PHP is trying to log in to the MySQL database with a username I am not supplying.

The error I am getting is:

Warning: mysql_query(): Access denied for user ‘radiocaf’@’localhost’ (using password: NO) in /home/radiocaf/public_html/layout.php on line 16

Warning: mysql_query(): A link to the server could not be established in /home/radiocaf/public_html/layout.php on line 16

I am definitely supplying a password, and am not using “radiocaf” as the username in my connect file, so after 3 hours of staring, I still can’t work out where I am going wrong.

Here is my code:

psl-config.php:

define("HOST", "localhost");

define("USER", "carl");

define("PASSWORD", "xxxxxxxxx");

define("DATABASE", "wlist");

db_connect.php

include_once 'psl-config.php';   // As functions.php is not included

$mysqli = new mysqli(HOST, USER, PASSWORD, DATABASE);

and then finally, the main page which is where I am receiving the error (I have cut out the HTML between the PHP:

ini_set('display_errors',1);
error_reporting(E_ALL);
//Include Connection PHP and connect
include_once('includes/db_connect.php');

//Check Connection
if ($mysqli->connect_error) {
    die('Connection failed: ' . $mysqli->connect_error);
};
if (!$query = mysql_query("SELECT * FROM (
    (SELECT * FROM users)
    UNION ALL
    (SELECT * FROM members)
) results
ORDER BY Name DESC")){
    die("Error: " . mysqli_error($mysqli));
}

if (!$result = $mysqli->query($query)){
printf("Error: %sn", $mysqli->error);
}

<HTML>

    echo "<table border='0' cellpadding='0' cellspacing='0'>";
        $x=0;
        while($row = mysql_fetch_assoc($result)):
        if ($x<10){
            echo "<tr><td width='400' height='30' background='../images/green1.jpg'>".$row["Name"]."</td></tr>";
        }

        $x++;

        if ($x == 10){
            echo "<tr><td width='400' height'30' background='../images/green1.jpg'>More...</td></tr>";
            break;
        }
        endwhile;
        echo "</table>";

<HTML>

$mysqli->close();

The surrounding HTML is just the layout of the page, essentially just a photoshop layout, sliced and exported to web.

I am fairly new to PHP and so I hope this question is as explained as possible.


Source: mysql

Leave a Reply