2014-02-17 28 views
0

我將不勝感激,如果有人能告訴我爲什麼即時得到一個語法錯誤與此代碼:插入到數據庫提供了語法錯誤

if(isset($_POST['submit'])) 
            { 
$dbcon = mysqli_connect("localhost","user1","test1","tutorial"); 



$stored_file = $_FILES["file"]["name"]; 

$query="INSERT INTO store (filname, uppladdare, titel) VALUES 


**Line 136->**('$_POST[**file**]$stored_file','$_POST[uppladdare]','$_POST[titel]')"; 
    if(!mysqli_query($dbcon ,$query)); 
             } 

公告:未定義的索引:在文件/應用/ XAMPP/xamppfiles/htdocs目錄/ projekt webb/laddaupp.php on line 136

該函數工作正常,我存儲所有我想要的數據。但我仍然有一個錯誤。 我總是可以通過使用reporting_error來「解決」這個問題。但我更願意從我的錯誤中學習。

/感謝

編輯: 星星都沒有編碼的一部分。只是爲了顯示錯誤發生的地方!

的最終結果:

$查詢=「INSERT INTO存儲(FILNAME,uppladdare,影片名稱) VALUES( '$ stored_file', '$ _ POST [uppladdare]', '$ _ POST [影片名稱]') 「;

感謝您的答案好朋友!:)

+0

英文:'跆拳道是$ _FILES [ 「文件」]'' – MonkeyZeus

+1

( -'$ _ POST [**文件**] $ stored_file''跆拳道#2張貼實際的代碼 –

+0

'回聲。'';'將有助於調試 – MonkeyZeus

回答

0

我認爲你可以使用可變$stored_file,你只存儲在您的文件名

$query="INSERT INTO store (filname, uppladdare, titel) 
VALUES ('$stored_file','$_POST[uppladdare]','$_POST[titel]')"; 

。在你的$_POST由於錯誤說,沒有沒有$_POST['file']$stored_file指數$_POST['file']

+0

非常感謝!解決了這個問題!:) – Winterwind

+0

你歡迎花花公子,如果你覺得答案是正確的,不要忘記接受它,這樣你也可以在將來也有類似問題的人幫助。 – Fabio

+0

葉,只需再等3分鐘;) – Winterwind