mysqli_fetch_array()期望参数1为mysqli_result,第37行给出布尔值

/* * Slenderman * Connect to database * @ return bool (connection) */ function db_connect(){

$connection = ysqli_connect("localhost","slenderman","slenderman");
if(!$connection){
    return false;
}   
if (!mysqli_select_db($connection, "joblicious")) {
    return false;
}
return $connection;

}

function find_jobs(){ db_connect();

$select = "SELECT jobs.id,
                  jobs.location,
                  jobs.title,
                  jobs.company,
                  jobs.description,
                  jobs.url";
$from = "FROM jobs.id";  
$where ="WHERE jobs.id >0";

$query = $select.$from.$where;
$result = mysqli_query(db_connect(),$query);

 while ($row = mysqli_fetch_array($result)){
    echo $row['id'];
 }

}

find_jobs();

You are getting this error because your query is returning false results.

  • Another problem is you have written

$from = "FROM jobs.id";

I think your table name is jobs so replace it with job and check the result using :

if(!empty($result)){

}

You miss blanks between the query parts. change

$query = $select.$from.$where;

to

$query = $select." ".$from." ".$where;

Also you should check for errors after every sql statement.

<?php 

function db_connection(){

    $connection = mysqli_connect("localhost","slenderman","slenderman");
    if(!$connection){
     return false;
    }
    if(!mysqli_select_db($connection,"joblicious")){
     return false;
    }
      return $connection;
    }


function find_jobs(){
         db_connection();


 $select =  ("SELECT jobs.id,
                    jobs.location,
                    jobs.title,
                    jobs.company,
                    jobs.description,
                    jobs.url ");
 $from = ("FROM jobs");
 $where = ("WHERE jobs.id >0");

 $query = $select." ".$from." ".$where;



    $result = mysqli_query(db_connection(),$query); 
    while($row = mysqli_fetch_array($result)){
    echo $row["title"];
   }
}
find_jobs();

?>

Your way of writing the SQL query is not encouraged. Try writing the query on the whole like this:

$query = "SELECT jobs.id, jobs.location, jobs.title, jobs.company, jobs.description, jobs.url FROM jobs.id WHERE jobs.id >0";

I am certain this error is coming due to improper syntax of the select statement (most probably due to the missing white-spaces).

Do take a look at the syntax manual of PHP in order to avoid such errors in the future.