Welcome to WebmasterWorld Guest from 54.146.217.179

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

syntax error, unexpected '{'

My code appears to need the {

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

New User

joined:July 4, 2013
posts: 15
votes: 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 July 11, 2013 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Nov 15, 2004
posts:1867
votes: 0


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

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

New User

joined:July 4, 2013
posts: 15
votes: 0


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

Administrator

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

joined:Aug 10, 2004
posts:10542
votes: 8


welcome to WebmasterWorld, ksklos!


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

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members