This question already has an answer here:
I am writing a time clock program and I am running into an error that I can not seem to find in the code. After looking over the code, I do not find an error where it says there is one. I did a check on PHP Code Checker too and it did not find one. Here is the code that I am using. I have modified the sensitive information. What am I doing wrong and how can I fix it. I was following the example on the 3rd answer here: display data from SQL database into php/ html table
Here is the output:
Fatal error: Call to undefined method mysqli::fetch_array() in path to file on line 31
Punch ID Time Punch Type Group Department Notes and the code
<head>
<title>View My Punches</title>
<body bgcolor="#9966FF">
<link rel="icon" type="image/ico" href="path to favicon"/>
</head>
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
define('DB_NAME', 'name');
define('DB_USER', 'user');
define('DB_PASSWORD', 'password');
define('DB_HOST', 'host');
$link = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if ($link->connect_errno > 0){
die('Could not connect: ' .connect_error());
}
$userid_value = $_POST['userid'];
$table = "tc_".$userid_value;
$checkusersql = "SELECT * FROM tc_users WHERE userid = '$userid_value'";
$usercheck = $link->query($checkusersql);
$punchessql = "SELECT * FROM $table";
$result = $link->query($punchessql);
if ($usercheck->num_rows == 0) {
echo "Sorry, " . $userid_value . " is not a valid user ID. Please try again.";
}else {
echo "<table>";
echo "<tr><td>Punch ID</td><td>Time</td><td>Punch Type</td><td>Group</td><td>Department</td><td>Notes</td></tr>";
while ($row = $link->fetch_array($result))
{
echo "<tr><td>" . $row['id'] . "</td><td>" . $row['time'] . "</td></tr>" . $row['punchtype'] . "</td><td>" . $row['groupname'] . "</td><td>" . $row['dept'] . "</td><td>" . $row['notes'] . "</td><td>";
}
echo "</table>";
}
?>
</div>