我不明白为什么这不更新我的数据,从文本输入接收:输入不会在MySQL表更新
include "config.php"
printf ("Update PriceList\n");
printf ("<form method=\"post\" action=\"price_red.php\">");
printf ("Select PhoneID: <input type = \"Text\" name = \"PhonID\"><br>");
printf ("PhoneName:<input type = \"Text\" name = \"PhoneName\"><br>");
printf ("PhoneType:<input type = \"Text\" name = \"PhoneType\"><br>");
printf ("ScreenType:<input type = \"Text\" name = \"ScreenType\"><br>");
printf ("Camera: <input type = \"Text\" name = \"Camera\"><br>");
printf ("Quantity: <input type = \"Text\" name = \"Quantity\"><br>");
printf ("Price:<input type = \"Text\" name = \"Price\"><br>");
printf ("Out of stock:<input type = \"Text\" name = \"outofstock\"><br>");
printf ("<input type=\"Submit\" name=\"submit\" value=\"Update\">");
printf ("</form>");
$sql = mysql_query("UPDATE PhonesPriceList SET PhoneName = '$PhoneName', Price = '$Price', Quantity = '$Quantity', Outofstock = '$outofstock' WHERE PhoneID = '$PhonID';");
$sql1 = mysql_query("UPDATE PhonesDetails SET PhoneType = '$PhoneType', ScreenType = '$ScreenType', Camera ='$Camera' WHERE PhoneID = '$PhonID';");
欢迎来到堆栈溢出!您在查询中没有执行任何错误检查。在* mysql_query()'调用之后,你需要*来做到这一点。否则,如果查询失败,脚本将中断。如何做到这一点在[mysql_query()'](http://php.net/mysql_query)手册或本[参考问题。](http://stackoverflow.com/questions/6198104/reference -what-a-perfect-code-sample-using-the-mysql-extension) –
你显示的代码也容易受到[SQL注入](http://php.net/manual/en/security.database .SQL-injection.php)。使用适当的卫生方法(例如'mysql_real_escape_string()'用于传统的mysql库),或切换到PDO并准备好语句。 –
$ PhoneName变量定义的变量 – craig1231