In a loop, the following function is executed twice in a row:

function CodeToURLImg($code) { $sql_catalog = 'SELECT Image FROM Message57 WHERE ItemID=' . $code; $query_catalog = mysql_query($sql_catalog); $row_catalog = mysql_fetch_array($query_catalog); $massiv = explode(":", $row_catalog[Image]); $CodeToURLImg = '/netcat_files/' . $massiv[3]; return $CodeToURLImg; } 

The first time returns a normal value, the second time it returns an error:

Warning: mysql_fetch_array () expects parameter 1 to be resource, given in /home/a/aas2ra/aas2ra.bget.ru/public_html/netcat/full.php(127): eval () 'd code on line 101

After turning on the display of errors, I also saw an error like this:

Notice: Constant Image - assumed 'Image' in /home/a/aas2ra/aas2ra.bget.ru/public_html/netcat/full.php(127): eval () 'd code on line 121

Both times the value in the function is passed the same. How to fix it?

    2 answers 2

     $massiv = explode(":",$row_catalog[Image]); 

    Amendment. It takes Image for a constant. It is necessary to screen quotes.

     $massiv = explode(":",$row_catalog['Image']); 

    Or (which is not recommended) create a constant.

     define('Image', 'Image'); $massiv = explode(":",$row_catalog[Image]); 
    • Shielded it with quotes. But the main problem did not pass with Warning: mysql_fetch_array () expects parameter 1 to be resource, given in /home/a/aas2ra/aas2ra.bget.ru/public_html/netcat/full.php(127): eval () 'd code on line 101 Request is still unwilling to execute - feramount
    • one
      Screen $ code Like this: $ sql_catalog = 'SELECT Image FROM Message57 WHERE ItemID = "'. $ Code. '";'; - Rijen
    • one
      All the error was gone. Thank you very much) - feramount

    I share my experience: In some cases, it is necessary to prescribe not $ _POST [user] in $ _POST [], but numeric values ​​$ _POST [0], $ _POST [1]

    • How is $_POST related to the question? - Regent
    • I advise you to get such an approach out of your head, and also to access global arrays directly, it is better to use the filter_ * functions for frequent. - And
    • This is a comment, not an answer. except that the text does not contain an answer to the question β€” it is also not clear how it relates to the question. "Apples and uncle in Kiev". - AK ♦