|
-
Jul 19th, 2014, 08:38 PM
#1
Thread Starter
Don't Panic!
[RESOLVED] Extra [ ....??
I'm missing something, and I don't know what.
I'm running the php apache and mysql using xampp on the home machine.
I'm trying to loop an array that should already be set (with either default data or text/numbers).
But when running I get :
Parse error: syntax error, unexpected '[' in C:\xampp\htdocs\PHP\QoS\qos_xs_tbl.php on line 193
Code:
for ( $Loop=0; $Loop<=$c; $Loop++) {
$al = aryData[$Loop][0];
/*
if ( $my == $al ) {
aryData[$Loop][1] = $row['TheValue'];
break;
}
*/
}
The line in bold is the error line (I think). Seems it doesn't want to parse the array.
Is there something I should look at that I've missed?
(it's giving me a headache)
I'm trying to read a record that has the month and year from mysql, compare that to the array (x)(0)... if it matches, then I'd put the value from the record into the array...
Repeat until the id changes, at which point it should output the array to the page, and reset the values.
Any pointers appreciated
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 20th, 2014, 12:10 AM
#2
Re: Extra [ ....??
Are you using notepad? Pls. try Notepad++ since it is going to give you the line number where the error occurred.
EDIT:
Try showing more code where you declared those arrays.
Last edited by dee-u; Jul 20th, 2014 at 12:31 AM.
-
Jul 20th, 2014, 06:49 PM
#3
Thread Starter
Don't Panic!
Re: Extra [ ....??
Still trying to get to grips with some of the differences in php to vba...
Hence looking more to the procedural style...
Um, aas to the declaring but, thought it did that as you use it. Mainly haven't seen any dim type statements. And other code I ran worked...
Below is the bit that sets up the array (first line)
Code:
// one year back - 13 months
$py = $sy -1;
$pm = $sm;
$cy = $py;
$cm = $pm - 1;
$c = 15;
// array to output onto page
$aryData[0][0] = 'Metric';
$aryData[1][0] = 'Current Target';
// loop for Month year (from prev to selected)
for ($Loop=2; $Loop<$c; $Loop++) {
$cm = $cm + 1;
if ($cm>12) {
$cm = 1;
$cy = $cy + 1;
}
$aryData[$Loop][0] = MonthName($cm, true) . '-' . substr($cy,2,2);
}
$FinYr = $_SESSION['TheYear'];
if ($_SESSION['TheMonth']<4) {
$FinYr = $FinYr -1;
}
$aryData[15][0] = 'YTD '. $FinYr;
// output to page...
echo '<tr>';
for ( $Loop=0; $Loop<=$c; $Loop++) {
echo '<th>' . $aryData[$Loop][0] . '</th>';
if ($Loop == 0) {
$aryData[$Loop][1] = '';
} else {
$aryData[$Loop][1] = 0;
}
}
echo '</tr>' . PHP_EOL;
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Jul 21st, 2014, 09:10 AM
#4
Thread Starter
Don't Panic!
Re: Extra [ ....??
In case people were wondering... its a missing $ before the aryData... So it thought that aryData was a constant and constants can't be arrays (so it didn't like the [ ).
Fixed... Running now...
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|