Home php warning: mysql_fetch_array () EXPECTS PARAMETER 1 TO BE RESOURCE

warning: mysql_fetch_array () EXPECTS PARAMETER 1 TO BE RESOURCE [Duplicate]

Author

Date

Category

warning: mysql_fetch_array () EXPECTS PARAMETER 1 TO BE RESOURCE, BOOLEAN GIVEN IN N: \ HOME \ Localhost \ www \ phpsite \ TestReg.php on line 36

How to make not issued an error?


Answer 1, Authority 100%

so as not to give out – @ in front of the function.
To avoid Errors, write like this:

$ result = @mysql_query ("Select` col` from `oshibka` Where ip = '$ ip'", $ db );
$ MYROW = Array ();
if (mysql_num_rows ($ result) & gt; 0) {
 $ myrow = mysql_fetch_array ($ result);
}

even better

try {
$ result = mysql_query ("Select` col` from `oshibka` Where ip = '$ ip'", $ db);
} Catch (Exception E) {
//Error processing
}

Answer 2, Authority 100%

It is also easier. Error is most likely in the request and we simply do not see it, but better to bring it and see!

$ result = mysql_query ($ sql) || DIE (mysql_error ());

Answer 3, Authority 50%

$ result = mysql_query ("Select col from oshibka where ip = '$ ip'", $ db);
if ($ result) {
  $ myrow = mysql_fetch_array ($ result);
}
ELSE {
  echo mysql_error ();
}

and everything ..


Answer 4

If you rinsed it right, then the request came empty and you throw it to another function.
It is necessary to make a plug, so that this does not happen. I do this:

$ result = mysql_query ("Select col from oshibka where ip = '$ ip'", $ db) or Die (' CANN`t Query '.Mysql_error);

Error occurs due to not matching types: The function accepts the type of Resource data, your request came empty, which is equivalent to False (Boolean).

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions