Menu

Fix mysql_fetch_array() Expects Parameter 1 to Be Resource
📰

Fix mysql_fetch_array() Expects Parameter 1 to Be Resource

DEV Community: database·Faizan·about 20 hours ago
#CBC34sa3
#devtodatabase#devto#dev#result#query
Reading 0:00
15s threshold

You'll learn how to identify the failed MySQL query behind the "expects parameter 1 to be resource" warning and fix it using modern, reliable PHP database code.

Time needed: Approximately 10–20 minutes.

If you're maintaining an older PHP application, you may encounter an error like this:

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given

Enter fullscreen mode

Exit fullscreen mode

The same warning can appear with several functions:

mysql_fetch_assoc() expects parameter 1 to be resource mysql_fetch_row() expects parameter 1 to be resource mysql_num_rows() expects parameter 1 to be resource

Enter fullscreen mode

Exit fullscreen mode

These warnings usually have one underlying cause: the SQL query failed, but the application tried to read its result anyway.

The fetch function is where the problem becomes visible.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.