我有以下的代碼行,除了一個順利執行正常。它會將變量名稱打印到數據庫中。PHP數據庫獲取變量
我用這個代碼在我scrips之一:
$con = mysql_connect("MyServer","MyDB","myPwd");
mysql_select_db("MyDB", $con);
$sql = "INSERT INTO `MyDB`.`Shipping` (`ID`, `FIRSTNAME`, `LASTNAME`, `ADDRESS1`, `ADDRESS2`, `CITY`, `STATE`, `ZIP`, `ORDERNUMBER`, `SHIPPINGTYPE`, `item1`, `item2`, `item3`, `item4`, `item5`, `item6`, `item7`, `item8`, `item9`, `item10`) VALUES (NULL, \'$first_name\', \'lname\', \'addr\', \'\', \'city\', \'state\', \'zip\', \'ordernum\', \'\', \'0\', \'0\', \'0\', \'0\', \'0\', \'0\', \'0\', \'0\', \'0\', \'0\');";
mysql_query("$sql");
mysql_close($con);
此代碼打印跟隨着到數據庫:
$first_name lname addr city state zip 0 0 0 0 0 0 0 0 0 0 0
注意,變量名,變量不是內容被打印。我怎樣才能打印出可變的內容?
請注意[SQL注入](http://en.wikipedia.org/wiki/SQL_injection) – cambraca 2012-04-06 21:14:55