0

super new/silly question. I'm getting a 'syntax error, unexpected end of file in X' in my HTML/PHP form below. The idea is super simple, connect to a database, and search a table, output the information. Is there any obvious syntactical problem below that's prohibiting this code from running? (Also do you guys happen to see any logical flaws that would prohibit it from running correctly?)

<?php    
//connect to DB
include("config.php");
$db = mysqli_connect(DB_SERVER,DB_USERNAME,DB_PASSWORD,DB_DATABASE);

//default output (for logic later)
$output = '';
//collect output from user
if(isset($_POST['search'])){

    $searchq = $_POST['search'];

    $query = mysqli_query($db, "SELECT * FROM tools WHERE toolName LIKE '%$searchq%' OR toolClassification LIKE '%$searchq%'") or die("Problem 2");
    $count = mysql_num_rows($query);
    if($count == 0){
        $output = 'there was no search results';    
     } else {

        while($row = mysql_fetch_array($query)) {
            $toolName = $row['toolName'];
            $toolClassification = $row['toolClassification'];

            $output .= '<div> '.$toolName.' '.$toolClassification.'</div>';
        }
     }

?>


<html>
<head>
<title> Search </title>
</head>
<body>
<form action="search2.php" method="post">
    <input type="text" name="search" placeholder="Search for tools...">
    <input type="submit" value=">>" />
</form>

<?php 

print("$output");

?>

</body>
</html>
Jorah
  • 1
  • 1
  • One ends '/>' and other this '>'one it's wrong. For you to learn a little more of html I recomend to use https://www.w3schools.com. – Jose Marques Apr 08 '17 at 18:33
  • @JoseMarques you're not completely wrong but that's not the problem about the code. The problem is in the php-code that the opening brackets { never have the same amount as the closing brackets } , in this case the shown error is typical. In detail the line "if(isset($_POST['search'])){" opens a block, that is not closed. So before you close the first php-block add a closing bracket }. – David Apr 08 '17 at 18:43

0 Answers0