gbarnes27 Posted October 29, 2013 Share Posted October 29, 2013 Getting a 500 internal server error when trying to display my search criteria. Server errror is: PHP Parse error: syntax error, unexpected $end in /var/www/html/SaaS/processform.php on line 63 I am very very new to all this so any help or suggestions would be greatly appreciated. Thanks <?php // include MySQL-processing classes require_once 'mysql.php'; try{ // connect to MySQL $db=new MySQL(array('host'=>'localhost','user'=>'*******','password'=>'*********','database'=>'SaaS')); $searchterm=$db->escapeString($_GET['searchterm']); $result=$db->query("SELECT * FROM servers WHERE Server LIKE '%$searchterm%'"); if(!$result->countRows()){ echo '<div class="maincontainer"><h2>No results were found. Goback and try a new search.</h2></div>'."*****************"; } else{ // display search results echo '<div class="maincontainer"><h2>Your search criteriareturned '.$result->countRows().' results.</h2>'."*******************"; while($row=$result->fetchRow()){ echo "<table border='1'><tr><th>Server Name</th><th>Application Name</th><th>Application Tower</th><th>Airline Name</th><th>Airline Code</th></tr>"; while($row = mysqli_fetch_array($result)) {echo "<tr>";echo "<td>" . $row['Server'] . "</td>";echo "<td>" . $row['application_Name'] . "</td>";echo "<td>" . $row['Application_Tower'] . "</td>";echo "<td>" . $row['Airline_name'] . "</td>";echo "<td>" . $row['Airline_code'] . "</td>"; echo "</tr>"; Quote Link to comment Share on other sites More sharing options...
mentalist Posted October 29, 2013 Share Posted October 29, 2013 This error probably means you haven't closed a {} pair. Which by the looks of that code you haven't in a few places, from a quick look (assuming that's all your code) you haven't closed 2 whiles, an if and a try... It would be easier if you'd put it in a code block too, then the indentation would be apparent and make debugging easier. Quote Link to comment Share on other sites More sharing options...
gbarnes27 Posted October 29, 2013 Author Share Posted October 29, 2013 I dont understand what you mean code block?? Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted October 29, 2013 Share Posted October 29, 2013 is that your full code? You have only posted 32 lines of code, yet the error states there is 63 lines. As mentalist said you most likely don't have matching { and } (these denote code blocks). If you do not know how to fix this error post your code for processform.php in full here within tags. Quote Link to comment Share on other sites More sharing options...
gbarnes27 Posted October 29, 2013 Author Share Posted October 29, 2013 (edited) <?php // include MySQL-processing classes require_once 'mysql.php'; try{ // connect to MySQL $db=new MySQL(array ('host'=>'localhost','user'=>'root','password'=>'hit.ear.cot-113', 'database'=>'SaaS')); $searchterm=$db->escapeString($_GET['searchterm']); $result=$db->query("SELECT * FROM servers WHERE Server LIKE '%$search } if(!$result->countRows()){ echo '<div class="maincontainer"><h2>No results were found. Go back and try a new search.</h2></div>'."*****************"; } else{ // display search results echo '<div class="maincontainer"><h2>Your search criteria returned '.$result->countRows().' results.</h2>'."******************* while($row=$result->fetchRow()){ echo "<table border='1'> <tr> <th>Server Name</th> <th>Application Name</th> <th>Application Tower</th> <th>Airline Name</th> <th>Airline Code</th> </tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Server'] . "</td>"; echo "<td>" . $row['application_Name'] . "</td>"; echo "<td>" . $row['Application_Tower'] . "</td>"; echo "<td>" . $row['Airline_name'] . "</td>"; echo "<td>" . $row['Airline_code'] . "</td>"; echo "</tr>"; } echo "</table>"; mysqli_close($con); ?> The new error is: PHP Parse error: syntax error, unexpected T_STRING in /var/www/html/SaaS/processform.php on line 21 Thanks again for taking time to help. Greg Edited October 29, 2013 by gbarnes27 Quote Link to comment Share on other sites More sharing options...
mentalist Posted October 29, 2013 Share Posted October 29, 2013 echo 'Your search criteria returned '.$result->countRows().' results.'."******************* You haven't closed this string... Maybe more... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.