文件PHP / HTML表单意外结束

时间:2017-04-08 18:11:49

标签: php html

超级新/愚蠢的问题。我在下面的HTML / PHP表单中遇到'语法错误,X中文件意外结束'。这个想法非常简单,连接到数据库,并搜索表,输出信息。下面是否存在明显的语法问题,禁止此代码运行? (你们也碰巧看到任何会阻止它正常运行的逻辑缺陷吗?)

<?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>

0 个答案:

没有答案