Results 1 to 4 of 4

Thread: mysql connectivity problem

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    mysql connectivity problem

    I connect php application to mysql from two different files from one file it

    is connecting and from other file it gives me following error message.

    Connection Failed because: Access denied for user 'ODBC'@'localhost' (using password: NO)

    even i am using same connection string in both files but still problem exist!!

    like in this way

    $dbh=mysql_connect ('localhost','newuser','mypass');


    PHP Code:
    $dbh=mysql_connect ('localhost','newuser','mypass');
    mysql_select_db ("twmweb");

    $result=mysql_query("select * from inventory");
    $EOF=mysql_num_rows($result); 
    above php code working

    but following sample function gives above error

    PHP Code:
    function connect() 
    {
        global 
    $db_name;
        
    $connection mysql_connect ('localhost','newuser','mypass');
         or  die(
    "Connection Failed because: " mysql_error() );

        
    $db mysql_select_db("twmweb" $connection) or die("Invalid database name " );
        return 
    $connection;

    i required help as soon as possible

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: mysql connectivity problem

    PHP Code:

        $connection 
    mysql_connect ('localhost','newuser','mypass');
         or  die(
    "Connection Failed because: " mysql_error() ); 
    I may be wrong but pretty sure thats not right, it should be...

    PHP Code:

        $connection 
    mysql_connect ('localhost','newuser','mypass') or die("Connection Failed because: " mysql_error() ); 

  3. #3
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: mysql connectivity problem

    @pino: you are correct.

    You need to change the line that pino said. and you error message is saying that you are using the username "ODBC" and you are not using a password.
    My usual boring signature: Something

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: mysql connectivity problem

    You're getting the error message because of the extra semicolon. You're calling mysql_error even when the connection succeeds, which means it spits out the last error message generated.

Posting Permissions

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



Click Here to Expand Forum to Full Width