Jump to content

[SOLVED] mysql_connect problem


gbos

Recommended Posts

Hi all,

 

I use the following code to connect to a mysql database:

 

if (isset($_POST['submit']))

{

        $conn = mysql_connect("localhost", $_POST['username'], $_POST['password']);

        if ($conn)

        {

        $db = mysql_select_db("bia") or die('Could not open BIA: ' . mysql_error());

        $_SESSION['logged'] = 1;

        header( 'location:assocmain.php' );

        }

        else

        {

        ?>

        <html>

        <head>

        .....more code here

 

My problem is that when  use it locally if works OK but when I use it on the hosting server I get the following message when a user either enters not username and password or the wrong username and password:

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'www-data'@'localhost' (using password: NO) in /mnt/red/www/website/associate/login.php on line 7

 

The message is printed on the screen as if it were echo'ed.

 

Can any one help?

Link to comment
Share on other sites

Yes the database is the same name on both servers, the local mysql server and the one on the web server.

 

And I should have mentioned that if the correct username and password is entered everything goes OK. No error messages.

 

 

Link to comment
Share on other sites

Thanks for the suggestion MasterACE14, I tried adding

 

error_reporting(E_ALL);

 

to the top of the code and I still got the error message:

 

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'www-data'@'localhost' (using password: NO) in /mnt/red/www/website/associate/login.php on line 8

 

The only difference was the line number.

 

Is there some kind of php configuration setting like "Echo warnings = OFF"?

 

That is what it seems like to me because this doesn't happen with the localhost database.

 

Thanks again.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.