1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Access Denied

Discussion in 'Web Design & Development' started by skyhigh007, Nov 12, 2007.

Thread Status:
Not open for further replies.
Advertisement
  1. skyhigh007

    skyhigh007 Thread Starter

    Joined:
    Jun 16, 2004
    Messages:
    592
    Hi
    I got this ERROR "Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO)" My root user does have a password. What is ODBC and how can I change it to root?
     
  2. Gibbs

    Gibbs

    Joined:
    Feb 28, 2005
    Messages:
    609
    You've made an error in your connection. Go to square one and try:

    PHP:
    mysql_connect("localhost""root""") or die (mysql_error());
    Any errors outputted?

    Edit: OBDC = Open Database Connectivity. It's what's used to connect "X" to the database.
     
  3. MMJ

    MMJ Guest

    Joined:
    Oct 15, 2006
    Messages:
    3,625
    How are you trying to connect?
     
  4. skyhigh007

    skyhigh007 Thread Starter

    Joined:
    Jun 16, 2004
    Messages:
    592
    function makeConnection() {
    $this->connection = mysql_connect( $this->hostname,
    $this->databaseUsername,
    $this->databasePassword) or trigger_error(mysql_error(),E_USER_ERROR);
    }
     
  5. Gibbs

    Gibbs

    Joined:
    Feb 28, 2005
    Messages:
    609
    Try:

    PHP:
    class MyClass
    {
        function 
    makeConnection() 
        {
            
    $this->connection mysql_connect("localhost""root""") or trigger_error(mysql_error(), E_USER_ERROR);
        }
    }

    $slick = new MyClass();
    $slick->makeConnection();
    Post your full code. Where is $this->hostname (etc) being defined?
     
  6. skyhigh007

    skyhigh007 Thread Starter

    Joined:
    Jun 16, 2004
    Messages:
    592
    class DB {
    //var $hostname, $database, $databaseUsername, $databasePassword, $databaseType, $recordCount, $debug;
    function DB($hostname, $database, $databaseUsername, $databasePassword, $databaseType = "MySQL"){
    $this->hostname = $hostname;
    $this->database = $database;
    $this->databaseUsername = $databaseUsername;
    $this->databasePassword = $databasePassword;
    $this->databaseType = strtolower($databaseType);
    $this->makeConnection();
    $this->debug = false;
    }
     
  7. Gibbs

    Gibbs

    Joined:
    Feb 28, 2005
    Messages:
    609
    I'm confused. Why are you running the makeConnection function outside of the class? It won't understand "$this" outside or in a different class.

    This would be easier:
    PHP:
    function makeConnection($hostname$databaseUsername$databasePassword$database)
    {
        
    mysql_connect($hostname$databaseUsername$databasePassword) or trigger_error(mysql_error(), E_USER_ERROR); 
        
    mysql_select_db($database) or trigger_error(mysql_error(), E_USER_ERROR); 
    }

    makeConnection("localhost",  "root""""my_database");
     
  8. skyhigh007

    skyhigh007 Thread Starter

    Joined:
    Jun 16, 2004
    Messages:
    592
    MakeConnection is not outside of the class, its a method of class DB
     
  9. Gibbs

    Gibbs

    Joined:
    Feb 28, 2005
    Messages:
    609
    Can you post the full code then please? Sorry but it's confusing me :p

    Also have you tried any of the alternatives I've thrown in? First of all you need to establish WHAT the problem is and then work with your code.
     
  10. MMJ

    MMJ Guest

    Joined:
    Oct 15, 2006
    Messages:
    3,625
    Was this working before?

    The error in your first post probably means that the user is incorrect. Echo the user variable and make sure it is root.
     
  11. skyhigh007

    skyhigh007 Thread Starter

    Joined:
    Jun 16, 2004
    Messages:
    592
    Im testing it on Vista and i think the default is ODBC ?how can i change it to root or the user name that i have created in PhpMyAdmin?
     
  12. MMJ

    MMJ Guest

    Joined:
    Oct 15, 2006
    Messages:
    3,625
    Grr... Check the user var as posted above. You need to help us help you.
     
  13. skyhigh007

    skyhigh007 Thread Starter

    Joined:
    Jun 16, 2004
    Messages:
    592
    In my phpmyadmin, I only have the Root and kick users. There's no ODBC.
     
  14. MMJ

    MMJ Guest

    Joined:
    Oct 15, 2006
    Messages:
    3,625
    Please read post #2 very carefully.
     
  15. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Similar Threads - Access Denied
  1. pyhton999
    Replies:
    2
    Views:
    396
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/651002

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice