所以我收到了这个错误:
警告:无法修改标题信息 - 已在第55行/Applications/MAMP/htdocs/add_user.php中发送的标题(在/Applications/MAMP/htdocs/add_user.php:50处开始输出)
第55行的代码是:
55 header(sprintf("Location: %s", $insertGoTo));
脚本以:
开头 <?php require_once('Connections/connHotel.php'); ?>
<?php
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"] == "userform")) {
$insertSQL = sprintf("INSERT INTO clients (title, firstName, lastName, address1, address2, town, province, country, postCode, telephone, email) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['firstName'], "text"),
GetSQLValueString($_POST['lastName'], "text"),
GetSQLValueString($_POST['address1'], "text"),
GetSQLValueString($_POST['address2'], "text"),
GetSQLValueString($_POST['town'], "text"),
GetSQLValueString($_POST['province'], "text"),
GetSQLValueString($_POST['country'], "text"),
GetSQLValueString($_POST['postcode'], "text"),
GetSQLValueString($_POST['telephone'], "text"),
GetSQLValueString($_POST['email'], "text"));
mysqli_select_db($connHotel, $database_connHotel);
$Result1 = mysqli_query($connHotel, $insertSQL) or die(mysqli_error($connHotel));
$insertGoTo = "booking_details.php?email=$email";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
我不明白警告的含义。
答案 0 :(得分:0)
必须在所有其他输出之前发送标头。确保在此之前不发送任何其他字符。即使你的PHP开场序列<?php
也不能包含任何前导字符。