Welcome to WebmasterWorld Guest from 174.129.96.175

Forum Moderators: coopster & jatar k

syntax error, unexpected '{'

My code appears to need the {

   
9:40 pm on Jul 11, 2013 (gmt 0)



I am trying to create a search and display form. Here is the php code:

<?php

if (isset($_Post['submitted'])) {

//Connect to the database
$include('connect.php');

$category = $_Post['category'];
$criteria = $_Post['criteria'];
$query = "Select * FROM Member WHERE $cateory = '$criteria'";
$result = mysqli_query($dbcon, $query) or die('error getting data');

echo "<table>";
echo "<tr><th>Member Number</th><th>First Name</th><th>Laast Name</th><th>Address</th><th>Address2</th><th>City</th><th>State</th><th>Zip</th><th>Phone</th><th>Chapter</th><th>Chapter Number</th></tr>";

while($row = (mysqli_fetch_array($result, MYSQLI_ASSOC)){

echo "<tr><td>";
echo $row['MemberNumber'];
echo "</td><td>";
echo $row['FName'];
echo "</td><td>";
echo $row['LName'];
echo "</td><td>";
echo $row['Address'];
echo "</td><td>";
echo $row['Address2'];
echo "</td><td>";
echo $row['City'];
echo "</td><td>";
echo $row['State'];
echo "</td><td>";
echo $row['Zip'];
echo "</td><td>";
echo $row['Phone'];
echo "</td><td>";
echo $row['Chapter'];
echo "</td><td>";
echo $row['ChapterNumber'];
echo "</td></tr>";

}

echo "</table>";

}//end of main if statement

?>

The line giving me the problem is the while statement. The error seems to say that I don't need the { at the end.
9:44 pm on Jul 11, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This:
while($row = (mysqli_fetch_array($result, MYSQLI_ASSOC)){

needs to be:
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
1:28 pm on Jul 12, 2013 (gmt 0)



Thank you. It's amazing how many times one can look at something and completely miss it.
1:50 pm on Jul 12, 2013 (gmt 0)

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



welcome to WebmasterWorld, ksklos!


it is helpful to use an editor that highlights based on language syntax, so you will see missing closures, etc.
 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month