open.mp forum
[Pawn] issue with forEach - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] issue with forEach (/showthread.php?tid=2556)



issue with forEach - CJ101 - 2024-01-19

Does open.mp not work with foreach? I get the error:
C:\Users\jdawg\OneDrive\Documents\RXDM\gamemodes\rxdm-sql.pwn(4887) : error 017: undefined symbol "Rows@YSII_Ag"

Here's part of my code, the error is on the foreach() line

Code:
mysql_query(rxdm,"SELECT * FROM `props`");
new Rows = cache_num_rows();
new tmp[35];
if(Rows > 0)
{
foreach (new row:Rows)
{



RE: issue with forEach - Threshold - 2024-01-19

Because your Rows are not defined as an Iterator; but seeing as cache_num_rows() only returns a single integer, there is no reason to use it for that purpose.
Code:
mysql_query(rxdm,"SELECT * FROM `props`");
new Rows = cache_num_rows();
if(Rows) {
    for(new i = 0; i < Rows; i++)
    {



RE: issue with forEach - alberta5 - 2024-07-25

Why does the foreach loop in the code snippet not work with open.mp, and how can it be modified to iterate over the result set of a SQL query using a for loop instead?