2016-04-15 86 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); 
    ?> 

回答

相關問題