Jump to content

Newbie Alert - Getting 500 Error on Php table creation


gbarnes27

Recommended Posts

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. 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>";

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

<?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 by gbarnes27
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.