我有以下php代码,这是应该连接到数据库和更新一些信息。然而,它并没有更新。它不会给出任何错误,它连接得很好……sql语句似乎不起作用,但在我看来一切都很好。
if ($send != "no") {
$db_name = "auctionfinal";
$table_name = "auctions";
$connection = @mysql_connect("auctionfinal.db.6084638.hostedresource.com", "xxxx", "xxxx") or die(mysql_error());
$db = @mysql_select_db($db_name, $connection) or die(mysql_error());
$sql = "UPDATE $table_name SET curbid = '$_POST[price]', nbids = '$totalnbid' WHERE aucname = '$auc' ";
$result = @mysql_query($sql, $connection) or die(mysql_error());
if ($result) {
echo "Thank you! You have bid on the auction for $auc, the current bid is $curbid, there have been $nbids bids on this auction so far.";
}
} else if ($send == "no") {
echo "$user_err";
} 发布于 2011-06-22 09:06:19
它不会给出任何错误,因为您已经告诉PHP忽略错误。删除所有mysql函数调用前面的"@“,您将得到错误。
发布于 2011-06-22 09:06:44
php mysql函数前面的"@“符号表示禁止任何错误。删除它,然后您将看到是否有任何错误。
发布于 2011-06-22 09:06:18
这是在字符串中使用变量扩展所冒的风险之一。
这句话:
$sql = "UPDATE $table_name SET curbid = '$_POST[price]', nbids = '$totalnbid' WHERE aucname = '$auc' ";..。最好写成:
$sql = "UPDATE ".$table_name." SET curbid = '".mysql_real_escape_string($_POST['price'])."', nbids = '".mysql_real_escape_string($totalnbid)."' WHERE aucname = '".mysql_real_escape_string($auc)."' ";https://stackoverflow.com/questions/6433774
复制相似问题