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
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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.