Hi there,

I have a little bit of a problem, i keep getting the following message when i try retrieve info from my database:

"mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given"

Here is my PHP code i don't see the error could someone please help?

    //Check if the connection has been set
    if(!isset($con)) {
    echo "<p>There was a problem connecting to the server, please try again later!</p>";
    //Select all data from table
    $query = "SELECT * FROM updates ORDER BY post_date DESC LIMIT 2";
    //Get the result
    $result = mysqli_query($con, $query);
    //Create array and post results
    while($entry = mysqli_fetch_array($result)) {
        echo "<div class='news_entry'>";
        echo "<p>" .$entry['post_header'] . "</p>";
        echo "<p>" .$entry['post_title'] . "</p>";
        echo "<p>" .$entry['post_entry'] . "</p>";
        echo "<p>" .$entry['post_date'] . "</p>";
        echo "</div>";

Please help...

Hi, at line 10 use mysqli_error():

if ( ! $result = mysqli_query($con, $query)) {
    printf("Errormessage: %s\n", mysqli_error($con));

It should explain the reason that makes the query return boolean FALSE.

Docs: http://php.net/manual/en/mysqli.error.php

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.