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

MySQL Best Practices

Trying to select data from a MySQL table, but getting the error messages:

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

– This may happen for various reasons like both the mysql_* and the mysqli extension will return false from their query functions.

– Using a die() you can get a little to much.

– Use mysql_error() which reports any errors that MySQL encountered while performing the query.

– If you have a syntax error in your query you can check with tools like phpMyAdmin.

– A missing quote around the mysql query or a value can cause a failure.

– Do not mix mysqli_* and mysql_* functions.

– Make sure you are escaping your all values.

Based on United States, Jacob Frazier is a skilled JavaScript developer with over 8 years of experience. He is passionate about change and trying new things, both professionally and personally. He loves startups and is extremely proactive.

You may like:  MySQL stored procedure parameters and variables

Leave a Reply

Your email address will not be published. Required fields are marked *