2013-11-26 88 views
0

這是一個表單處理程序爲我的web表單處理後提交web表單沒有任何錯誤,我仍然不能 看到mysql中新添加的記錄。請幫助數據從網絡表格不顯示在mysql表

請問任何人都可以告訴我做錯了什麼?

<?php 
$_POST['id']; 
$_POST['fname']; 
$_POST['lname']; 
$_POST['house_no']; 
$_POST['street_name']; 
$_POST['postcode']; 
$_POST['email']; 
$_POST['tel']; 
$_POST['comments']; 

    $host = ""; 
    $user = ""; 
    $pass = ""; 
    $data = "moodscontact"; 
$cxn = mysql_connect($host,$user,$pass) or die('Connection Failed ' . mysql_error($cxn)); 

mysql_select_db($data); 

$query =" 
INSERT INTO moodstable(
id,fname,lname,house_no,street_name,postcode,email,tel,comments) 
VALUES 
(null'$fname','$lname','$house_no','$street_name','$postcode','$email','$tel','$comments')"; 

if(isset ($_POST['submit'])){ 
print 'Query succeeded'; 
} 
else 
{ 
die('Submission failed ' . mysql_error()); 
    } 

mysql_close($cxn); 
?> 
+2

逗號是在缺少'VALUES (空 '$ FNAME','。 –

回答

0

丟失,在插入查詢

$query =" 
INSERT INTO moodstable(
id,fname,lname,house_no,street_name,postcode,email,tel,comments) 
VALUES (NULL,'$fname','$lname','$house_no','$street_name','$postcode', 
'$email','$tel','$comments')"; 

更好地利用這個查詢

$query =" 
INSERT INTO moodstable(
fname,lname,house_no,street_name,postcode,email,tel,comments) 
VALUES ('$fname','$lname','$house_no','$street_name','$postcode', 
'$email','$tel','$comments')";