I write a script, here it is: $tmp = mysql_fetch_row ($select); , on the server gives an error? Why?

 $myrow = mysql_fetch_array($result); if ($myrow['col'] > 2) { exit("Вы набрали логин или пароль неверно 3 раз. Подождите 15 минут до следующей попытки."); } $password = md5($password); $password = strrev($password); $password = $password."b3p6f"; $result = mysql_query("SELECT * FROM users WHERE login='$login' AND password='$password'",$db); $myrow = mysql_fetch_array($result); 

Mistake:

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in Z:homephpwwwtestreg.php on line 8 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in Z:homephpwwwtestreg.php on line 17 Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in Z:homephpwwwtestreg.php on line 21

Closed due to the fact that it was off-topic by Athari , Shilgen , Sergey , Yura Ivanov , fori1ton 6 May '15 at 6:39 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • "The question is caused by a problem that is no longer reproduced or typed . Although similar questions may be relevant on this site, solving this question is unlikely to help future visitors. You can usually avoid similar questions by writing and researching a minimum program to reproduce the problem before publishing the question. " - Athari, Shilgen, Yura Ivanov, fori1ton
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • 2
    always write the text of the error and format the script code - RedMonkey
  • one
    @ anton, edit the question. At the moment, nothing is clear. - Nicolas Chabanovsky
  • "Help write a script here it is $ tmp = mysql_fetch_row ($ select);" $ tmp = mysql_fetch_row ($ select); is there a script? On the server gives an error! What error does the server give? Why half the code? Put the desired piece! Or rather, speak out) - LordySL 7:01 pm
  • Added to the question. - Anton
  • @ Anton What kind of error occurs on the server? - LordySL

2 answers 2

 Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in Z:homephpwwwtestreg.php on line 8 

hints at what

 $tmp = mysql_fetch_row ($select);, // как бы сначала нужно сделать запрос 

like that

 $select="SELECT * FROM table WHERE blah-bla"; $result=mysql_query($select); // ну а дальше по сценарию делать что нужно. 

    The request was not made correctly, variables are not substituted in the request in this way, I usually did this:

     $sql = "SELECT * FROM table WHERE login='" . mysql_real_escape_string($login) . "' AND password='" . mysql_real_escape_string($password) ."'" $result = mysql_query($sql); $row = mysql_fetch_row($result);