2015-11-01 86 views
-1

我試圖顯示來自數據庫的數據輸出,但顯示錯誤。我想創建論壇,將顯示同一頁上的消息顯示論壇數據時出錯

我的錯誤是:

$ 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>"; 
     } 
    } 

}` 
+3

刪除美元之前mysqli_query – amdixon

+1

我不認爲你做了足夠的研究之前問這個問題.. – MikeWu

回答

0

你有函數調用0123前,這是變量的語法,而不是函數。

+0

我已經刪除它。並顯示警告:mysqli_query()期望至少2個參數 –

+0

瞧,它確實如此:https://secure.php.net/manual/en/mysqli.query.php RTFM – Jameson

+0

非常感謝ypu。它真的幫助:) –