Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2011
    Thanked 0 Times in 0 Posts

    mysql_connect Access Denied

    So I'm testing out a page on a hosted server. However they're technical help so far has just assumed it to be a coding error and so far unhelpful.

    It's pretty simple, I just can't get mysql_connect() to work. The exact error I get in the log is this:

    [04-Aug-2011 00:06:02] PHP Warning: mysql_connect() [<a href='function.mysql-connect'>function.mysql-connect</a>]: Access denied for user 'rtechnix'@'localhost' (using password: NO) in /home/rtechnix/protected/DbConnect.php on line 12

    The exact code being referenced is below with line-12 bolded:

    class Db {

    protected static $server = 'localhost';
    protected static $username = 'rtechnix_admin';
    protected static $password = '*****';

    public static function connect() {
    if(!isset($dbconn)) {
    global $dbconn;
    $dbconn = mysql_connect($server, $username, $password) or die ('Error connecting to database.');

    The username and password (obviously edited out here) are EXACTLY as they appear and were created in the cPanel Database manager. I cannot for the life of me figure out how to fix this. I'm scared this may be a mysql issue that I don't have access to fix with the hosting company and since they're being somewhat useless right now..

    Thanks in advance.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Thanked 2,224 Times in 2,211 Posts
    $dbconn = mysql_connect($server, $username, $password) or die ('Error connecting to database.');
    Shouldn't that be
    PHP Code:
    $dbconn mysql_connect($this->server$this->username$this->password) or die ('Error connecting to database.'); 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Super Moderator guelphdad's Avatar
    Join Date
    Mar 2006
    St. Catharines, Ontario Canada
    Thanked 148 Times in 139 Posts
    This part of the error message:
    (using password: NO)

    means that the password is not being sent through correctly, it isn't the wrong password, just no password is being sent.


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts