Home>

make a request for each selected checkbox

foreach ($ _ POST ['check'] as $ value) {
    $ t= 'SELECT * FROM catalog WHERE id= "'. $ value. '"';
        echo $ t; //output to view the request
    $ mysql_afhgahf= mysql_query ("SELECT * FROM catalog WHERE id= '". $ value. "'");
    $ mysql_fetch= mysql_fetch_array ($ mysql_afhgahf);
    echo $ mysql_fetch ['description']. "<
br />
";
                    }

ordinary requests, it would seem, only when selecting, for example, all checks, it throws an error, and errors fly out for some reason! Meaning

SELECT * FROM catalog WHERE id= "19"
Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in L: \ home \ localhost \ www \ versal_anapa.ru \ admin \ catalog \ operations.php on line 28
SELECT * FROM catalog WHERE id= "18"
Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in L: \ home \ localhost \ www \ versal_anapa.ru \ admin \ catalog \ operations.php on line 28
SELECT * FROM catalog WHERE id= "17"
Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in L: \ home \ localhost \ www \ versal_anapa.ru \ admin \ catalog \ operations.php on line 28
SELECT * FROM catalog WHERE id= "16"
Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in L: \ home \ localhost \ www \ versal_anapa.ru \ admin \ catalog \ operations.php on line 28
SELECT * FROM catalog WHERE id= "20"
Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in L: \ home \ localhost \ www \ versal_anapa.ru \ admin \ catalog \ operations.php on line 28
SELECT * FROM catalog WHERE id= "21"
Warning: mysql_fetch_array () expects parameter 1 to be resource, boolean given in L: \ home \ localhost \ www \ versal_anapa.ru \ admin \ catalog \ operations.php on line 28

these are the errors! who will tell me?

the request failed, see the documentation for how to get the mysql error. and so -just in case, what you use as an argument for mysql_query () and what echo is different lines. what stops you from using $ t= is not clear.

zb'2021-11-25 23:16:23

What good sql injection looks at us from your code! At least now in the textbook.

VladD2021-11-25 23:16:23

all requests are correct ... there are no errors, the $ t variable contains the request that is used in the selection ... only he swears for no reason at all! sometimes it displays such errors, but this is how everything works ... I don't understand why it fails, because everything is correct?!?!?

tagir2021-11-25 23:16:23

They wrote to you, check: if ($ mysql_afhgahf) {...} else {print mysql_error (); } If there is an error, it will be displayed.

lightcyber2021-11-25 23:16:23

@tagir, the request will return either the required resource or false. Your code does not provide for the return of false at all. Hence the mistake (if in a short perspective).

etki2021-11-25 23:16:23