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

warning mysql_fetch_array() expects parameter 1 to be resource, boolean given in php is the common error displayed while doing any php projects. If there is any syntax error in sql query it will display the error. Follow the following steps to overcome the error,

  • First run the sql query by using phpMyAdmin tool. If any errors it will display you can correct your query here.
  • Once check the database connection is established.
  • Finally check the query is executed or not before fetching the data. Use mysql_query() function to execure the sql query.
  • If you are running the sql based on the user input then use mysql_real_escape_string() function to prevent sql Injection.