PHP mysqli_query expects at least 2 parameters

so my problem is with this code gives me the
Warning: mysqli_query() expects at least 2 parameters, 1 given in C:wampwwwforumcreate_cat.php on line 13
if any1 knows what is there to be fixed here pls help


$sql = "SELECT
        cat_id,
        cat_name,
        cat_description,
    FROM
        categories";

$result = mysqli_query($sql);
if(!$result)
{
echo 'The categories could not be displayed, please try again later.';
}
else
}
if(mysqli_num_rows($result) == 0)
{
        echo 'No categories defined yet.';
}
else
{
 echo '<table border="1">
          <tr>
            <th>Category</th>
            <th>Last topic</th>
          </tr>'; 
  while($row = mysqli_fetch_assoc($result))
    {     
 echo '<tr>';
            echo '<td class="leftpart">';
                echo '<h3><a href="category.php?id">' . $row['cat_name'] . '</a></h3>' . $row['cat_description'];
            echo '</td>';
            echo '<td class="rightpart">';
                        echo '<a href="topic.php?id=">Topic subject</a> at 10-10';
            echo '</td>';
        echo '</tr>';
  }
}

and i`m using this other file to connect to mydb

$server = 'localhost';
$username   = 'root';
$password   = '';
$database   = 'project yi';
 $link=mysqli_connect($server, $username,  $password, $database);


Source: wampserver

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.