I'm new to PHP and am looking for some beginner help. I don't understand why this simple while loop is not working. I've checked for syntax errors with various variations and don't think that's the case.
The error says:
Fatal error: Uncaught Error: Call to undefined function mysql_fetch_assoc() in /opt/lampp/htdocs/basic-procedural-php-project/index.php:77 Stack trace: #0 {main} thrown in /opt/lampp/htdocs/basic-procedural-php-project/index.php on line 77
The code is as follows:
<?php include 'db.php'; ?>
<?php
// Fetch data from db
$query = 'SELECT * FROM data';
$numbers = mysqli_query($con, $query);
?>
<?php while ($row = mysql_fetch_assoc($numbers)) : ?>
<p>whatever <?php echo $row['t_name'] ?></p>
<?php endwhile; ?>
The database is as follows:
DB NAME: timesNumbers
DB TABLE NAME: data
COLUMNS: t_id, t_name, t_firstNo, t_secondNo
Can someone explain what the error means, the problem and how to fix it? I feel like it might be something basic that I'm not getting. Thanks for and help here.
Also the db.php file includes:
<?php
// Connect
$con = mysqli_connect("localhost", "root", "", "timesNumbers");
// Test Connection
if (mysqli_connect_errno()) {
echo 'Failed: '.mysqli_connect_error();
}
?>