Avatar ·

Error "expects parameter 1 to be resource" when using mysql_fetch_array() in PHP

Hello everyone! I'm a beginner in PHP and MySQL, and I have a problem that I can't seem to solve. I'm writing a simple script to output data from the users table. Here's my code: ```php $connection = mysql_connect('localhost', 'root', ''); mysql_select_db('test', $connection); $query = "SELECT * FROM users"; $result = mysql_query($query); while ($row = mysql_fetch_array($result)) { echo $row['name'] . '
'; } ``` But instead of the expected list of names, I get this error: "Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in ..." I checked the database connection — it seems to work. Tell me, what am I doing wrong? Why isn't $result a resource? I tried different options: mysql_fetch_assoc(), mysql_fetch_row() — the same error everywhere. Maybe the problem is...