im trying to connect to my mysql server
$this->dblink = mysql_connect("kemistry","root","password");

this gives me an error:
PHP Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root '@'Server' (using password: YES) in c:\Inetpub\wwwroot\Server\lib\forumDB.php on line 20

i created a new root@Server and im using the correct password but im still getting the access denied error. what am i doing wrong?

    What version of PHP ? What version of MySQL ?

    I know that someday, MySQL changed its way to encrypt passwords, and PHP, at that moment, had trouble with that since it used the "old" encryption..

      mysql = 5.0.17
      php=5

      since the password in mysql is encrypted do i have to pass the password in using the mysql_connect encrypted?

        Are you connecting to the same server that your script is on? If so, try using "localhost" as the host name. If it's an external server and if that server allows external database connections, you'll probably need a port number with the host name, e.g.:

        $connx = mysql_connect('hostname.com:xxx', 'username', 'password') or die('DB connection failed: ' . mysql_error());
        

        Change the "xxx" to whatever port number is configured for external DB connections.

          they are both the same server. I changed the host to localhost and Im getting the same error:
          PHP Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root '@'localhost' (using password: YES)

          also I put the mysql port number into the host address 3306

            Unless there's a password mis-match, you've got me stumped. 🙁

            Can you connect as root via the command line or phpMyAdmin? Are you sure you've got the right password (and remember that it's case-sensitive)? Sorry if those are stupid questions, but just want to be sure we're not missing something simple.

              i doubt its a password mismatch. if it is its the password that is passed throught the mysql_connect cause Im useing a variable to pass it in. ill look into that and get back.

                well i am sorry to waste everyones time. it was a password problem. I was reading my connection variables from a settings file. i wrote a class to load the file settings to an array. there was a newline character at the end of every line that I forgot about. I checked the length of the variable being passed in and it was 1 character larger than it was supposed to be. DUUUUUUHHHHHHH mmmmmeeeeee!!!!!

                  LOL - glad you figured it out.

                  Glad I've never made a mistake like that. :rolleyes: [innocent whistling] :rolleyes:

                    Write a Reply...