mysql_error doesn't generate error message

Go To StackoverFlow.com

0

Error message doesn't display on mysql connect failure

        if( ! $this->remote_connection_id = @mysql_connect($vars['hostname'], $vars['username'], $vars['password'], TRUE))
        {
            die('Could not connect: ' . mysql_error());
        }

only displays Could not connect:

2012-04-05 21:11
by Oleksandr IY
Worked for me. I got a (suppressed) warning from the failed login and mysql_error also contained the same error message about not beeing able to login without a password. PHP 5.3.8 MySQL 5.5.2 - Basti 2012-04-05 21:40


0

Try

$mysqli = new mysqli ( $vars ['hostname'], $vars ['username'], $vars ['password'], "test" );
if ($mysqli->connect_errno) {
    printf ( "Connect failed: %s\n", $mysqli->connect_error );
}
else
{
    echo "Am OK" ;

}

Thanks

:)

2012-04-05 21:34
by Baba
no no no. I meant mysqlerror() doesn't display error message. I made this rootq to test error generating part. But mysqlerror() doesn't display error message, you see - Oleksandr IY 2012-04-05 21:38
Just updated the answe - Baba 2012-04-05 21:49


0

Try adding parentheses properly.

Instead of:

if( ! $a = foo())

Use:

if( !($a = foo()))

The reason you get no error is because the connection was successful.

2012-04-05 21:13
by Niet the Dark Absol
no i get php error message like Access denied for user 'rootq'@'localhost' (using password: NO)Oleksandr IY 2012-04-05 21:15
Well then, if you can't even connect to MySQL, it can't send you errors.. - Niet the Dark Absol 2012-04-05 21:16
since it says "using password: NO", you should check that your $vars is set correctly - Marc B 2012-04-05 21:29
no no no. I meant mysqlerror() doesn't display error message. I made this rootq to test error generating part. But mysqlerror() doesn't display error message, you see - Oleksandr IY 2012-04-05 21:38
That's because failing to connect is not a MySQL error - Niet the Dark Absol 2012-04-05 21:50


0

Do you have 2 connections? like this:

$link_lang_db = mysql_connect($conf_lang_db_host, $conf_lang_db_user, $conf_lang_db_password, 1) or die('Could not connect: ' . mysql_error($link_lang_db));
$link_editor_db = mysql_connect($conf_editor_db_host, $conf_editor_db_user, $conf_editor_db_password, 1) or die('Could not connect: ' . mysql_error($link_editor_db));

then try this:

$result = mysql_query($query24f, $link_lang_db) or die("Error: " .mysql_error($link_lang_db));

Hope it helped.

2012-10-07 06:17
by chrisiek
Ads