0

I am playing around with this trying to pull some articles from a database.

Here is the code i have so far: ($host etc are defined in config)

                   include ("admin/config.php");
                    $mysqli = mysqli_connect($host, $user , $pass , $database);

                    $query = "SELECT * FROM articles ORDER BY date LIMIT 5";
                    $result = mysqli_query($mysqli,$query);


                    while($row = mysqli_fetch_array($result))
                    {
                                            Some code to display results



                                             }

This is the error that gets generated but i just cant see what i am doing wrong. Any help will be much appreciated.

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /website....

4

1 回答 1

2

您的查询中有错误。
让它始终以这种方式运行所有查询

$result = mysqli_query($mysqli,$query) or trigger_error($mysqli->error."[$query]");
于 2013-02-01T19:41:44.987 回答