2016-04-15 85 views
0

我正在写一个简单的数据库来练习,但我不断收到此错误:致命错误:调用一个成员函数查询()布尔

致命错误:调用一个成员函数查询()上布尔在/Applications/XAMPP/xamppfiles/htdocs/index.php在线43

查询行是第43,但我不明白为什么它是一个布尔值既不$conn$db_handlefalse,这是为什么?

<?php 

    $server = "localhost"; 
    $database = "motocross_db"; 
    $username = "root"; 
    $password = ""; 

    $conn = new mysqli($server, $username, $password); 
    $db_handle = $conn->select_db($database); 

    if ($db_handle) 
    { 
     if ($_SERVER['REQUEST_METHOD'] == 'POST') 
     { 
      // upload 
     } 

     $enrollments_sql = "SELECT 
           users.first_name, 
           users.last_name, 
           registrations.attendance_date, 
           registrations.attendance_location, 
           bikes.bike_brand, 
           bikes.engine_size, 
           bikes.bike_type 
         FROM users 
         INNER JOIN registrations 
          ON users.user_id = registrations.user_id 
         INNER JOIN bikes 
          ON registrations.bike_id = bikes.bike_id"; 

     $enrollments_result = $db_handle->query($enrollments_sql); 
    ?> 

回答

相关问题