Hi all,
Could anyone tell me how to sort out this error: Warning: Cannot modify header information - headers already sent by (output started at /home/reachate/public_html
/Connectio
ns/GSM_bac
kup.php:4)
in /home/reachate/public_html
/Remote/no
kiaremoter
eturnlive.
php on line 57
Not sure what to do with it?
Here's the page and the connection file.
Thanks so much,
D
<?php require_once('../Connectio
ns/GSM_bac
kup.php');
?>
<?php
// Deconcatenate the varaiables in the 'os0' post field...
$customVar = $_REQUEST['custom'];
$arrayVar = explode("---",$customVar);
$IMEI = $arrayVar[0];
$username = $arrayVar[1];
$email = $arrayVar[2];
function GetSQLValueString($theValu
e, $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_STR
ING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUE
RY_STRING'
]);
}
if ((isset($_POST["MM_insert"
])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO nokia_removal_table (nokia_username, nokia_email_add, nokia_IMEI_nr) VALUES (%s, %s, %s)",
GetSQLValueString($_POST['
nokia_user
name'], "text"),
GetSQLValueString($_POST['
nokia_emai
l_add'], "text"),
GetSQLValueString($_POST['
nokia_IMEI
_nr'], "int"));
mysql_select_db($database_
GSM_mobile
, $dbh);
$Result1 = mysql_query($insertSQL, $dbh) or die(mysql_error());
$insertGoTo = "../mainpage.php";
if (isset($_SERVER['QUERY_STR
ING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
$name = $_POST['txt_name'] ;
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml"
>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<form id="nokia_return" name="nokia_return" method="post" action="">
</form>
<form method="post" name="form1" action="<?php echo $editFormAction; ?>">
<table align="center">
<tr valign="baseline">
<td nowrap align="right">Username:</t
d>
<td><input name="nokia_username" type="text" value="<?php echo $username; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">Email Address:</td>
<td><input type="text" name="nokia_email_add" value="<?php echo $email; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right">IMEI Number</td>
<td><input type="text" name="nokia_IMEI_nr" value="<?php echo $IMEI; ?>" size="32"></td>
</tr>
<tr valign="baseline">
<td nowrap align="right"> </td>
<td><input type="submit" value="Insert record"></td>
</tr>
</table>
<input type="hidden" name="MM_insert" value="form1">
</form>
<p> </p>
</body>
</html>
And here's the connection (it works fine for other pages)
<?php
$dbh=mysql_connect ("localhost", "reachate_mainuse", "xxx") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("reachate_corkgsmdb");
?>
Start Free Trial