473,326 Members | 2,114 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Scope Woes - IF statement nested in WHILE statement -PHP

7
Scope Woes - IF statement nested in WHILE statement -PHP

I have an array $actuals_sum.
<?php
while(conditions)
{


if($i == '24)
{

$actuals_sum[$j] = 'bar';

$j = $j + 1;
}

}


echo $actuals_sum[1];

?>
---------


but.... it throws an ERROR and says $actuals _sum is undefined....

So the scope is LOCAL, i need to make it return GLOBAL.

-Hyrum
Reply With Quote
Apr 25 '07 #1
1 1861
tolkienarda
316 100+
Scope Woes - IF statement nested in WHILE statement -PHP

I have an array $actuals_sum.
<?php
while(conditions)
{


if($i == '24)
{

$actuals_sum[$j] = 'bar';

$j = $j + 1;
}

}


echo $actuals_sum[1];

?>
---------


but.... it throws an ERROR and says $actuals _sum is undefined....

So the scope is LOCAL, i need to make it return GLOBAL.

-Hyrum
Reply With Quote

you aren't entering your if statement cause you have single quote before the 24 it you want to check if it is a string then you will need another single quote if you want it to be an int then you need to get rid of the first single quote

eric
Apr 25 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Paul Charlton-Thomson | last post by:
Hi, I am trying to execute 2 queries and then output the results in 2 loops but maybe I'm using the wrong approach. Can anyone help me here ... $query_1 = "SELECT field_1 FROM table_1";...
26
by: Joshua Beall | last post by:
Hi All, I remember reading that both nested classes and namespaces would be available in PHP5. I know that namespaces got canceled (much sadness...), however, I *thought* that nested classes...
4
by: muser | last post by:
I have a logical error in my program, I have submitted the program and my tutor hasn't listed the other problems with the code, but said that the program won't run because of a while statement....
4
by: James E Koehler | last post by:
I can't get the WHILE statement to work in MySQL. The version of MySQL that I am using is: Ver 12.16 Distrib 4.0.6-gamma, for Win95/Win98 (i32) running on Windows MX. Here is the relevant...
36
by: invni | last post by:
I have a nested while. How do I go from the inner while to the beginning of the outer while? Can this be done without using goto? while_1() { some codes here while_2() { if true go to the...
2
by: desktop | last post by:
I have this nested while: int numsx = { 11, 22, 33, 44, 55, 77, 88, 99}; int* startx = numsx; int endx = sizeof(numsx) / sizeof(numsx); int* endxp = numsx + endx;
25
by: LBinGA | last post by:
Hello all: I'm having trouble with a nested If Statement working properly. I'm working in MS Access 2002 (OS Windows XP, ver 2002). The non-working code is going on the Form (a Single) as follows:...
4
by: lyle777 | last post by:
I am having trouble with the nested if statement. can anyone tell me where i went wrong with this code? the syntax error starts by the else statement within the target of the first if statement....
2
by: Kakashi | last post by:
My problem is when I try to run the while loop that is nested in the do while loop it fails to even enter into it. Am I missing something here, I do not have any errors or anything. The try catch...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.