Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 出现意外的T_变量_Php - Fatal编程技术网

Php 出现意外的T_变量

Php 出现意外的T_变量,php,Php,突出显示的语法有什么错误 <?php mysql_connect("localhost", "root", "") or die("could not connect"); mysql_select_db("student") or die("could not connect"); //collect if(isset($_POST['search'])) { $searchq = $_POST['search']; $searchq = preg_replace("

突出显示的语法有什么错误

<?php
mysql_connect("localhost", "root", "") or die("could not connect");
mysql_select_db("student") or die("could not connect");


//collect
if(isset($_POST['search'])) {
    $searchq = $_POST['search'];
    $searchq = preg_replace("#[^0-9a-z]#i", "", $searchq)

//here
$query = mysql_query("SELECT * FROM user WHERE registration LIKE '%$searchq%'") or die("could not search!");

    $count = mysql_num_rows($query);
    if($count == o){
        $output = 'There was no search results!';
    }else{
        while($row = mysql_fetch_array($query)) {
            $fname = $row['firstname'];
            $lname = $row['surname'];
            $id = $row['registration'];

            $output .= '<div> '.$id.' '.$fname.' '.$lname.'</div>';

}
?>


<html>
<head>
</head>
<body>

<form action="form.php" method="post">
    <input type="text" name="search" placeholder="search for students.."
    <input type="submit" value=">>" />
</form>


<?php print("$output");?>
</body>
</html>

您忘记了分号:

//collect
if(isset($_POST['search'])) {
    $searchq = $_POST['search'];
    $searchq = preg_replace("#[^0-9a-z]#i", "", $searchq)
应该是

//collect
if(isset($_POST['search'])) {
    $searchq = $_POST['search'];
    $searchq = preg_replace("#[^0-9a-z]#i", "", $searchq);

请它们不再得到维护,而是在使用。改为了解,并使用或。您缺少一个
分号找到它!您还缺少一个
}
。请不要使用堆栈溢出来调试您的代码。我相信您有一个“o”而不是“0”(零):如果($count==o){看,这很简单,您的所有答案都在这里:您只需阅读并找到它!我认为与其给您答案,不如了解错误的含义,发生了什么,以便下次您可以自己解决这个问题!“而且,看起来直接跟在后面的那条线也少了一条。。。"-是谁?谁投了这一票?解决了这一切,而不仅仅是1/2;-)感谢rm_vanda和其他人纠正了代码。事实上我是php新手。所以我面临着这种类型的问题。如果stackoverflow中不允许出现这种问题,那么我肯定会离开网站。请让我知道。@Nasim:是的,避免询问有关语法错误的问题。基本的syn税收是我们最不希望别人知道的。