2012-03-25 224 views
1

我一直試圖通宵完成這件事,沒有任何運氣。由於某種原因表單提交,但數據不會發送到數據庫。 繼承人PHP部分提交表格將不會提交數據到數據庫

<?php 

mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB"); 
if (isset ($_POST['Submit'])) //If submit is hit 
{ 
    $name = $_POST['name']; 
    $category = $_POST['category']; 
    $class = $_POST['class']; 
    $level = $_POST['level']; 
    $bind = $_POST['bind']; 
    $tier = $_POST['tier']; 
    $trade = $_POST['trade']; 
    $ilvl = $_POST['ilvl']; 
    $amod = $_POST['amod']; 
    $xdmg = $_POST['xdmg']; 
    $description = $_POST['description']; 
    $description2 = $_POST['description2']; 
    $description3 = $_POST['description3']; 
    $sprice = $_POST['sprice']; 
    $bprice = $_POST['bprice']; 
    $percent = $_POST['percent']; 
    $source = $_POST['source']; 
    $tnail = $_POST['tnail']; 
    $result=MYSQL_QUERY("INSERT INTO items (name, category, class, level, bind, tier, trade, ilvl, amod, xdmg, description, description2, description3, sprice, bprice, percent, source, tnail)". 
    "VALUES ('$name', '$category', '$class', '$level', '$bind', '$tier', '$trade', '$ilvl', '$amod', '$xdmg', '$description', '$description2', '$description3', '$sprice', '$bprice', '$percent', '$source', '$tnail')")or die("<p><span style=\"color: red;\">Unable to select table</span></p>"); 
    mysql_close(); 
    //confirm 
    echo "<p><span style=\"color: red;\">Thank You; the items have been entered in the database. DO NOT REFRESH THE PAGE or data will be sent again.</span></p>"; 
} 
else 
{ 
    // close php so we can put in our code 
?> 

任何幫助嗎?

+0

哇,從來沒有聽說過SQL注入的? – Shikiryu 2012-03-25 09:31:50

+0

是您的「MYSQL_QUERY」都在首都? – 2012-03-25 09:32:18

+0

@WaynnLue表示無所謂。 – Shikiryu 2012-03-25 09:34:23

回答

1

試圖關閉就像(`name`,`category`你的字段名......等

0

將調用mysql_query()後,下面的代碼的任何地方。

echo mysql_error(); 

如果有的話它會告訴你是不對您的查詢或數據庫憑據。