-4

Whenever I run this code below, I get Parse error: syntax error, unexpected '}', expecting ',' or ';' in C:\wamp\www\bee\hivedetails.php on line 52. I have looked at the code and (to me) it looks correct. Any help will be greatly appreciated.

<?php $HiveID=htmlspecialchars($_GET["HiveID"]); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://www.w3.org/2005/10/profile">
    <title>Hive Track</title>
    <link rel="stylesheet" type="text/css" href="style.css" />

    <!--[if IE]>
        <style type="text/css">
            #content {width: 770px; border-left: 2px solid #D1D1D1; border-right: 2px solid #D1D1D1; padding: 15px; margin: 0; background: url('images/content-bg.png');}
            table {border: 2px solid #AAAAAA;}
        </style>
    <![endif]-->

    <!--[if IE 9]>
        <style type="text/css">
            #content {width: 766px; margin: 0 auto; padding: 15px; background: url('images/content-bg.png');}
            table {border: 3px solid white; box-shadow: 0 0 10px #AAAAAA;}
        </style>
    <![endif]-->
</head>
<body>
    <div id="page">
        <div id="title">
            <h1>Hive Track</h1>
            <p></p>
        </div>

        <div id="body">
            <div id="nav">
                <ul>
                    <?php include 'nav.php'; ?>
                </ul>
            </div>

            <div id="header">
            </div>

            <div id="content">
                <?php if ($HiveID>=1) { echo "<h1>Hive Details</h1>";
                } else { echo "<h1>Create A New Hive</h1>";
                } ?>

                <?php if ($HiveID>=1) { echo
                "<?php mysql_select_db('hives'); 
                $query = mysql_query(' . SELECT * FROM hives WHERE HiveID = '$HiveID'') or die(mysql_error()); 
                if(mysql_num_rows($query)>=1){
                while($row = mysql_fetch_array($query)) {
                $hivename = " . $row["HiveName"] . ";
                $location = " . $row["LocationID"] . ";
                } }?>" } else { echo
                "$hivename='';$location='';" } ?>

                <h5></h5><br>
                <?php if ($HiveID>=1) {
                echo "Hive ID: " . $HiveID;
                } ?>
                <form action="hivedetailprocess.php" method="post">
                <input type="hidden" name="HiveID" value=<?php echo $HiveID; ?>>
                Hive Name: <input type="text" name="hivename" value=<?php echo $hivename; ?>> <br>





                <br><br>

                <!--<h5>Code</h5><br>
                <code>&lt;div&gt;&lt;p&gt;This is a code box.&lt;/p&gt;&lt;/div&gt;</code>


                <br><br><br><br>

                <h5>Blockquote</h5><br>
                <blockquote>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec purus tortor, adipiscing sed vehicula ut, condimentum in arcu. Fusce hendrerit massa non velit dictum a laoreet felis consectetur."</blockquote>


                <br><br>

                <h5>Lists</h5>
                <ol>
                    <li>Ordered List Item</li>
                    <li>Ordered List Item</li>
                    <li>Ordered List Item</li>
                    <li>Ordered List Item</li>
                    <li>Ordered List Item</li>
                </ol>
                <ul>
                    <li>Unordered List Item</li>
                    <li>Unordered List Item</li>
                    <li>Unordered List Item</li>
                    <li>Unordered List Item</li>
                    <li>Unordered List Item</li>
                </ul>-->

            </div>

            <div id="footer">
                <p><a href="">Website Name</a></p>
            </div>
        </div>
    </div>
</body>

Michael
  • 113
  • 1
  • 1
  • 11
  • 4
    That's what happens whithout proper code indention. – mario Nov 12 '12 at 00:06
  • 1
    You need to indent your code, it's hardly readable! As a side note, please use [PDO](http://php.net/pdo.construct) instead of `mysql_*` functions, as `mysql_*` functions are no longer maintained and are in the process of deprecation. – uınbɐɥs Nov 12 '12 at 00:13
  • 1
    Sorry, everything is indented on my editor, didn't stay that way when I copied and pasted. – Michael Nov 12 '12 at 02:59

2 Answers2

4

You need a semicolon after both echo's in lines 51 and 52

     } }?>"; } else { echo
     "$hivename='';$location='';"; } ?>
David Müller
  • 5,291
  • 2
  • 29
  • 33
0

Here is your working CODE

<?php $HiveID=htmlspecialchars($_GET["HiveID"]); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml">
<head profile="http://www.w3.org/2005/10/profile">
    <title>Hive Track</title>
    <link rel="stylesheet" type="text/css" href="style.css" />

    <!--[if IE]>
        <style type="text/css">
            #content {width: 770px; border-left: 2px solid #D1D1D1; border-right: 2px solid #D1D1D1; padding: 15px; margin: 0; background: url('images/content-bg.png');}
            table {border: 2px solid #AAAAAA;}
        </style>
    <![endif]-->

    <!--[if IE 9]>
        <style type="text/css">
            #content {width: 766px; margin: 0 auto; padding: 15px; background: url('images/content-bg.png');}
            table {border: 3px solid white; box-shadow: 0 0 10px #AAAAAA;}
        </style>
    <![endif]-->
</head>
<body>
    <div id="page">
        <div id="title">
            <h1>Hive Track</h1>
            <p></p>
        </div>

        <div id="body">
            <div id="nav">
                <ul>
                    <?php include 'nav.php'; ?>
                </ul>
            </div>

            <div id="header">
            </div>

            <div id="content">
                <?php if ($HiveID>=1) { echo "<h1>Hive Details</h1>";
                } else { echo "<h1>Create A New Hive</h1>";
                } ?>

                <?php if ($HiveID>=1) { echo
                "<?php mysql_select_db('hives'); 
                $query = mysql_query(' . SELECT * FROM hives WHERE HiveID = '$HiveID'') or die(mysql_error()); 
                if(mysql_num_rows($query)>=1){
                while($row = mysql_fetch_array($query)) {
                $hivename = " . $row["HiveName"] . ";
                $location = " . $row["LocationID"] . ";
                } }?>";  } else { echo
                "$hivename='';$location='';" ; } ?>

                <h5></h5><br>
                <?php if ($HiveID>=1) {
                echo "Hive ID: " . $HiveID;
                } ?>
                <form action="hivedetailprocess.php" method="post">
                <input type="hidden" name="HiveID" value=<?php echo $HiveID; ?>>
                Hive Name: <input type="text" name="hivename" value=<?php echo $hivename; ?>> <br>





                <br><br>

                <!--<h5>Code</h5><br>
                <code>&lt;div&gt;&lt;p&gt;This is a code box.&lt;/p&gt;&lt;/div&gt;</code>


                <br><br><br><br>

                <h5>Blockquote</h5><br>
                <blockquote>"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec purus tortor, adipiscing sed vehicula ut, condimentum in arcu. Fusce hendrerit massa non velit dictum a laoreet felis consectetur."</blockquote>


                <br><br>

                <h5>Lists</h5>
                <ol>
                    <li>Ordered List Item</li>
                    <li>Ordered List Item</li>
                    <li>Ordered List Item</li>
                    <li>Ordered List Item</li>
                    <li>Ordered List Item</li>
                </ol>
                <ul>
                    <li>Unordered List Item</li>
                    <li>Unordered List Item</li>
                    <li>Unordered List Item</li>
                    <li>Unordered List Item</li>
                    <li>Unordered List Item</li>
                </ul>-->

            </div>

            <div id="footer">
                <p><a href="">Website Name</a></p>
            </div>
        </div>
    </div>
</body>
admoghal
  • 1,498
  • 1
  • 10
  • 5