I'm a PHP beginner, so please forgive me for this question.
I am working on code someone else wrote a long time ago. The code was written without curly braces in many places, which for the most has been ok. However I am getting an error message that -for the code snippet I posted below- would read like this:
Notice: Undefined variable: f in ... on line 3.
Precisely a section that has a couple of loops and conditionals without braces. I am wondering if adding them will solve things. My problem is that I am very uncertain about where to add those braces since I don't know how many statements are within an IF or FOR that is not using the braces.
Could someone help me/show me where they would go on these lines of code? I'd appreciate it a lot.
Thanks so much,
Mauricio
Expand|Select|Wrap|Line Numbers
- for($x = 0;$x < $index;$x++)
- if($arr[$x] == $this->clistarray[0][$i]) $f = 1;
- if($f) continue;
- $arr[$index++] = $this->clistarray[0][$i];
- if($articleadded == 0)
- {
- $articleadded = 1;
- $this->enter_article($today);
- }
- printf("<br><b>Article has keyword </b> %s corresponding to country_id %d",$this->clistarray[1][$i],$this->clistarray[0][$i]);
- $t = $this->clistarray[0][$i];
- $insvpmainquery = "INSERT INTO `vpmain` ( `vpmain_id` , `article_id` , `country_id` ) VALUES ('', '$this->articleid', '$t')";
- mysql_query($insvpmainquery);