FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Tables created in the database but problem in access

 


bukaida
Hi
I have created a database with appropriate username and password. The tables were also created successfuly. But while inserting the data, the table is showing error.

Code:
Warning: mysql_connect() [function.mysql-connect]: Access denied for user: 'root@localhost' (Using password: NO) in /mydomain../gbook/lib/mysql.class.php on line 30
Connection Error
--------------------------------------------------------------------------------

MySQL Error : Connection Error
Error Number: 1045 Access denied for user: 'root@localhost' (Using password: NO)
Date        : Sat, January 6, 2007 03:05:27
IP          : 220.225.82.98
Browser     : Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon)
Referer     :
PHP Version : 4.4.4
OS          : Linux
Server      : Apache/1.3.37 (Unix) mod_python/2.7.11 Python/2.2.3 mod_ssl/2.8.28 OpenSSL/0.9.7a PHP/4.4.4 mod_perl/1.29 FrontPage/5.0.2.2510
Server Name : www.pratik.frih.net


the code was running fine on my local machine.I am also attaching the class file

Code:
<?php

class gbook_sql {

    var $conn_id;
    var $result;
    var $record;
    var $db = array();
    var $port;

    function gbook_sql() {
        global $GB_DB;
        $this->db = &$GB_DB;
        if(ereg(":",$this->db['host'])) {
            list($host,$port) = explode(":",$this->db['host']);
            $this->port = $port;
        } else {
            $this->port = 3306;
        }
    }

    function connect() {
        $this->conn_id = mysql_connect($this->db['host'].":".$this->port,$this->db['user'],$this->db['pass']);
        if ($this->conn_id == 0) {
            $this->sql_error("Connection Error");
        }
        if (!mysql_select_db($this->db['dbName'], $this->conn_id)) {
            $this->sql_error("Database Error");
        }
        return $this->conn_id;
    }

    function query($query_string) {
        $this->result = mysql_query($query_string,$this->conn_id);
        if (!$this->result) {
            $this->sql_error("Query Error");
        }
        return $this->result;
    }

    function fetch_array($query_id) {
        $this->record = mysql_fetch_array($query_id,MYSQL_ASSOC);
        return $this->record;
    }

    function num_rows($query_id) {
        return ($query_id) ? mysql_num_rows($query_id) : 0;
    }

    function num_fields($query_id) {
        return ($query_id) ? mysql_num_fields($query_id) : 0;
    }

    function free_result($query_id) {
        return mysql_free_result($query_id);
    }

    function affected_rows() {
        return mysql_affected_rows($this->conn_id);
    }

    function close_db() {
        if($this->conn_id) {
            return mysql_close($this->conn_id);
        } else {
            return false;
        }
    }

    function sql_error($message) {
        global $TEC_MAIL;
        $description = mysql_error();
        $number = mysql_errno();
        $error ="MySQL Error : $message\n";
        $error.="Error Number: $number $description\n";
        $error.="Date        : ".date("D, F j, Y H:i:s")."\n";
        $error.="IP          : ".getenv("REMOTE_ADDR")."\n";
        $error.="Browser     : ".getenv("HTTP_USER_AGENT")."\n";
        $error.="Referer     : ".getenv("HTTP_REFERER")."\n";
        $error.="PHP Version : ".PHP_VERSION."\n";
        $error.="OS          : ".PHP_OS."\n";
        $error.="Server      : ".getenv("SERVER_SOFTWARE")."\n";
        $error.="Server Name : ".getenv("SERVER_NAME")."\n";
        echo "<b><font size=4 face=Arial>$message</font></b><hr>";
        echo "<pre>$error</pre>";
        if (eregi("^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@([0-9a-z][0-9a-z-]*[0-9a-z]\\.)+[a-z]{2,5}$", $TEC_MAIL) ) {
            $headers = "From: $TEC_MAIL\r\nX-Mailer: Advanced Guestbook 2";
            // @mail("$TEC_MAIL","Guestbook - Error","$error","$headers");
        }
        exit();
    }

}

?>


Please help.
mathiaus
Quote:
Access denied for user: 'root@localhost' (Using password: NO)

You cannot use root on Frihost. You need to find where $this->db['user'] and $this->db['pass'] are defined and replace them with your newly created database username and password.
bukaida
Thanx mathiaus. Things are working now following your suggestions.
Reply to topic    Frihost Forum Index -> Support and Web Hosting -> Frihost Support

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.