[請益] 資料庫相關
我用Dreamweaver插入記錄功能把form裡的資料放入資料庫
有幾個form已經是成功的
不過突然有一個一直遇到以下錯誤
Warning: Invalid argument supplied for foreach() in
C:\AppServ\www\XXX.php on line 37
Warning: Cannot modify header information - headers already
sent by (output started at C:\AppServ\www\XXX.php:37)
in C:\AppServ\www\XXX.php on line 53
不知道有沒有哪位大大知道如何解決??
有點冗長...黃色為第53行
藍色為第37行
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
foreach($_POST['pizza _name'] as $i => $val){
$insertSQL = sprintf("INSERT INTO pizza_order (ordernum, pizza_name, Vegetable, PS, Price) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($_POST['ordernum'], "text"),
GetSQLValueString($_POST['pizza _name'][$i], "text"),
GetSQLValueString($_POST['Vegetable'][$i], "text"),
GetSQLValueString($_POST['PS'][$i], "text"),
GetSQLValueString($_POST['Price'][$i], "int"));
mysql_select_db($database_products, $products);
$Result1 = mysql_query($insertSQL, $products) or die(mysql_error());
}
$insertGoTo = "index.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 123.193.146.62
→
06/18 17:24, , 1F
06/18 17:24, 1F
※ 編輯: kinglislie 來自: 123.193.146.62 (06/18 17:27)
推
06/18 17:28, , 2F
06/18 17:28, 2F
→
06/18 17:31, , 3F
06/18 17:31, 3F
→
06/18 17:32, , 4F
06/18 17:32, 4F
→
06/18 18:02, , 5F
06/18 18:02, 5F
→
06/18 18:03, , 6F
06/18 18:03, 6F
→
06/18 18:04, , 7F
06/18 18:04, 7F
→
06/18 18:04, , 8F
06/18 18:04, 8F
討論串 (同標題文章)
PHP 近期熱門文章
PTT數位生活區 即時熱門文章