mysqli_query上的mysqli错误,说我有一个布尔值

时间:2014-05-08 22:22:40

标签: php sql mysqli

嘿伙计我得到一个非常令人沮丧的错误,我一直收到以下错误:Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given它说它在100行但我找不到它!

function connect_db ($dbname) {
    # Connect to the database, this failing should show that the DB isnt there
    $dbc = @mysqli_connect ('localhost','root','', $dbname);
    if($dbc) {
        mysqli_set_charset($dbc, 'utf8' ) ;
        return $dbc;
    }
    # Create the database
    $dbc = @mysqli_connect ('localhost', 'root', '', 'limbo_db');
    $query = 'CREATE DATABASE ' . 'limbo_db';
    $results = mysqli_query($dbc,$query);
    check_results($dbc, $results);
    # Close connection since we dont need it
    mysqli_close($dbc);
    # Connect to the (newly created) database
    $dbc = @mysqli_connect ('localhost','root','', $dbname)
        OR die ( mysqli_connect_error() ) ;
    # Set encoding to match PHP script encoding.
    mysqli_set_charset( $dbc, 'utf8' ) ;
    return $dbc;
}

0 个答案:

没有答案