Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 761845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:53:13+00:00 2026-05-14T15:53:13+00:00

I have set the password for root and grant all privileges for root. Why

  • 0

I have set the password for root and grant all privileges for root. Why does it say it is denied?

****mysql_query() [function.mysql-query]: Access denied for user 'SYSTEM'@'localhost' (using password: NO) in C:\wamp\www\photo_gallery\includes\database.php  on line 56

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in C:\wamp\www\photo_gallery\includes\database.php on line 56

The Query has problemAccess denied for user 'SYSTEM'@'localhost' (using password: NO)

Code as follows:

<?php
include("DB_Info.php");

class MySQLDatabase
{
    public $connection;
    function _construct()
    {
        $this->open_connection();
    }
    public function open_connection()
    {   
        $this->connection = mysql_connect($DB_SERVER,$DB_USER,$DB_PASS);
        if(!$this->connection)
        {
            die("Database Connection Failed" . mysql_error());
        }
        else
        {
            $db_select = mysql_select_db($DB_NAME,$this->connection);
            if(!$db_select)
            {
                die("Database Selection Failed" . mysql_error());
            }
        }
    }
    function mysql_prep($value)
    {
        if (get_magic_quotes_gpc())
        {
             $value = stripslashes($value);
        }
        // Quote if not a number
        if (!is_numeric($value))
        {
            $value = "'" . mysql_real_escape_string($value) . "'";
        }
        return $value;

    }
    public function close_connection()
    {
        if(isset($this->connection))
        {
            mysql_close($this->connection);
            unset($this->connection);
        }
    }
    public function query($sql)
    {

        $result = mysql_query($sql);
        $this->confirm_query($result);
        return $found_user;
    }
    private function confirm_query($result)
    {
        if(!$result)
        {
            die("The Query has problem" . mysql_error());
        }
    }

}

$database = new MySQLDatabase();



?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:53:14+00:00Added an answer on May 14, 2026 at 3:53 pm

    The missing second underscore for __construct() in

    class MySQLDatabase
    {
        public $connection;
        function _construct()
        {
    

    explains all the symptoms (mysql_query raising the warning, no undefined variable notices, no matter what you do to make the parameters available to function open_connection() it doesn’t work simply because it’s never called, access denied for system@localhost because your webserver runs as localsystem and therefore system is the default username for the default mysql connection, …)

    When you create a new object via $database = new MySQLDatabase(); the method _construct() isn’t invoked and therefore neither is $this->open_connection() and therefore no value is assigned to the property $connection which remains NULL and no connection to the mysql server is established.
    Now when you call $database->query('something'); and there is no database connection mysql_query() tries to establish the default connection as explained at http://docs.php.net/mysql_query:

    resource mysql_query ( string $query [, resource $link_identifier ] )

    […]
    If the link identifier is not specified, the last link opened by mysql_connect() is assumed. If no such link is found, it will try to create one as if mysql_connect() was called with no arguments. If no connection is found or established, an E_WARNING level error is generated.


    • Fix the typo in _construct()
    • pass $this->connection to mysql_real_escape_string(), mysql_query() and mysql_error()
    • make sure open_connection() has all the parameters it needs, e.g. isset($DB_SERVER,$DB_USER,$DB_PASS,$DB_NAME) or die('missing parameters');
    • add some debug output to see whether it has been called at all, e.g. echo "Debug: this->connection = mysql_connect($DB_SERVER,$DB_USER,$DB_PASS);\n";
    • don’t roll your own MySQL class, use one of the gazillion existing classes, preferably one with broader acceptance.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have a MySQL database set up on a Debian server and it
I use PhpMyAdmin to setup mysql tables and such. I also have root (full)
I am currently trying to install MySQL Server 5.5 on Windows XP Professional. The
So I have my UITableView, with 2 sections and 1 cell in each, and
I installed MySql on my own machine. I created database, create table, ... using
First off, does anyone know of a good place to get help with CodeIgniter?
I have VBScript inside a HTA getting the ping status from a local WMI
I have a directory and I want to allow users which are only logged
i started using oauth2 gem by intridea ( http://github.com/intridea/oauth2 ) and don't know how
How can I sync local and remote folders using rsync from inside a php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.