Forum Moderators: coopster

Message Too Old, No Replies

Syntax error missing braces

         

chrisguk

11:50 am on Jul 4, 2016 (gmt 0)

10+ Year Member



Hi there,

My IDE is reports a syntax error in the following php code but I can't work out where the error is:



<?php
$result = [
[ 'Plan Details' ],
[ 'Home' ],
[ 'Home+' ]
];

echo '
<div class="describeThisSection">';

if ($stmt = $con->query('SELECT * FROM day_pack')) {

// basically rotate the data set 90 degrees
while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
$i = 0; // use our own index as *** knows what your keys are
foreach ($row as $data) result[$i++][] = $data;
}

foreach ($result as $data)
{
echo '

<div>
<h4>', $data[0], '</h4>
<ul>
<li>', $data[1], '</li>
<li>', $data[2], '</li>
<li>', $data[3], '</li>
</ul>
</div>';
}
} else echo '
<h4>Prepare Failed:</h4>
<pre>', print_r($con -> errorInfo()), '</pre>';


?>



It points to the line 16 of the code above. Can anyone assist please?

LifeinAsia

1:27 pm on Jul 4, 2016 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Did you try the following? Change
foreach ($row as $data) result[$i++][] = $data;
to
foreach ($row as $data) {
$
result[$i++][] = $data;
}

lucy24

5:07 pm on Jul 4, 2016 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Did you mean "result" or "$result"?

A text editor with syntax highlighting is a big help, because anything that's in plain type-- or the wrong color-- will jump right out at you.