Jump to content

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
https://forums.phpfreaks.com/topic/73065-solved-mysql_connect-problem/
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.

 

I figured it out. Thanks to the assistance give via this site and particularly MasterAce.

 

If i add

 

error_reporting(0);

 

The error is not reported. Which is what I want. Check out:

 

http://www.phpfreaks.com/phpmanual/page/function.error-reporting.html

 

for detail.

 

Thanks again.

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.