homepage Welcome to WebmasterWorld Guest from 23.20.63.27
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
syntax error, unexpected '{'
My code appears to need the {
ksklos




msg:4592246
 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.

 

Habtom




msg:4592247
 9:44 pm on Jul 11, 2013 (gmt 0)

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

needs to be:
while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){

ksklos




msg:4592431
 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.

phranque




msg:4592435
 1:50 pm on Jul 12, 2013 (gmt 0)

welcome to WebmasterWorld, ksklos!


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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved