我試圖顯示來自數據庫的數據輸出,但顯示錯誤。我想創建論壇,將顯示同一頁上的消息顯示論壇數據時出錯
我的錯誤是:
$ mysqli_query($的SQL);
注意:未定義的變量:mysqli_query
致命錯誤:函數名稱必須是一個字符串
我的編碼是
` 如果(修剪($ _ 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>";
}
}
}`
刪除美元之前mysqli_query – amdixon
我不認爲你做了足夠的研究之前問這個問題.. – MikeWu