• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] issue with forEach
#1
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)
{
  Reply
#2
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++)
    {
  Reply
#3
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?
  Reply


Forum Jump: