显示论坛数据时出错

时间:2015-11-01 07:15:12

标签: php html mysql sql

我试图从数据库中显示数据的输出,但它显示错误。我想创建将在同一页面上显示消息的论坛

我的错误发生在:

$ mysqli_query($ SQL);

注意:未定义的变量:mysqli_query

致命错误:函数名称必须是字符串

我的编码是

`         if(trim($ _ POST [' forum_numberUser'])== NULL || trim($ _ POST [' forum_text'])== NULL)

       { // If the user didn't fill in all fields
        echo "<h3>PLEASE COMPLETE THE FORM TO REGISTER</h3>";
    }
    else {
        include('connect.php');

        $_SESSION['FILLED'] = TRUE;
        // username and password sent from form 
        $mynumberUser=$_POST['forum_numberUser']; 
        $mytext=$_POST['forum_text'];
       // $mydate=$_POST['forum_date'];


        // To protect MySQL injection (more detail about MySQL injection)
        $mynumberUser = stripslashes($mynumberUser);
        $mytext = stripslashes($mytext);
        $mynumberUser = mysql_real_escape_string($mynumberUser);
        $mytext = mysql_real_escape_string($mytext);
        $mydate=date('Y-m-d H:i:s');
        //$mytime=date('H:i:s');

        $sql = "INSERT INTO forum VALUES(null, '$mynumberUser', '$mytext', '$mydate')";
       $mysqli_query($sql); //HERE IS MY ERROR...


        if(mysqli_query($conn, $sql) === TRUE) {


             //&['forum_text']
            echo "Successfully registered ";
        }
        else {
            echo "<h4>Unable to register.</h4>";
        } 
    }

}`

1 个答案:

答案 0 :(得分:0)

在函数调用$之前有mysqli_query(),这是变量的语法,而不是函数。