From: "Gabor Hojtsy" <gabor@hojtsy.hu>
Reply-To: gabor@hojtsy.hu
To: "haydar" <hayddar@hotmail.com>, <webmaster@php.net>
Subject: Re: need help please
Date: Sat, 10 Jan 2004 15:39:45 +0100 (CET)
Please ask support questions at php-general@lists.php.net. I would
suggest you read the manual page of header() and headers_sent() before
you ask there though.
Regards,
Gabor Hojtsy
hello
i have this probleme
i include a connection file to the db
then i update i record and finaly i want to redirect it to another
page using header function but i have the following error
Warning: Cannot modify header information - headers already sent by
(output started
my code is :
<?php require_once('../Connections/vb_conn.php');?>
<?php ob_start(); ?>
<?php global $gifname;
$gifname=rand(1,1000);
$gifname=$gifname.".gif";
global $jpgname;
$jpgname=rand(1000,10000);
$jpgname=$jpgname.".jpg";
if(is_uploaded_file($pic))
{ global $myvar;
$myvar = $HTTP_POST_FILES['pic']['name'];
$cd = getcwd();
$wd = $cd."/pics";
chdir($wd);
if($dir=@opendir('.'))
{ if($HTTP_POST_FILES['pic']['type']=="image/gif")
{
if(file_exists($GLOBALS['myvar']))
{
rename($GLOBALS['myvar'],$GLOBALS['gifname']);
}
copy($HTTP_POST_FILES['pic']['tmp_name'],$dir);
if(file_exists("Resource id #1")) {
rename("Resource id #1",$GLOBALS['myvar']);
}
elseif(file_exists("Resource id #2")) {
rename("Resource id #2",$GLOBALS['myvar']);
}
elseif(file_exists("Resource id #3")) {
rename("Resource id #3",$GLOBALS['myvar']);
}
elseif(file_exists("Resource id #4")) {
rename("Resource id #4",$GLOBALS['myvar']);
}
}
if($HTTP_POST_FILES['pic']['type']=="image/jpeg")
{
if(file_exists($GLOBALS['myvar']))
{
rename($GLOBALS['myvar'],$GLOBALS['jpgname']);
}
copy($HTTP_POST_FILES['pic']['tmp_name'],$dir);
if(file_exists("Resource id #1")) {
rename("Resource id #1",$GLOBALS['myvar']);
}
elseif(file_exists("Resource id #2")) {
rename("Resource id #2",$GLOBALS['myvar']);
}
elseif(file_exists("Resource id #3")) {
rename("Resource id #3",$GLOBALS['myvar']);
}
elseif(file_exists("Resource id #4")) {
rename("Resource id #4",$GLOBALS['myvar']);
}
closedir($dir);}
}
}
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 = $HTTP_SERVER_VARS['PHP_SELF'];
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$editFormAction .= "?" . $HTTP_SERVER_VARS['QUERY_STRING'];
}
if ((isset($HTTP_POST_VARS["MM_insert"])) &&
($HTTP_POST_VARS["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO iss_pages (iss_id, pg_name,
pg_alt, pg_order, pg_display) VALUES (%s, %s, %s, %s, %s)",
GetSQLValueString($HTTP_POST_VARS['page_id'],
"int"),
GetSQLValueString($GLOBALS['myvar'], "text"),
GetSQLValueString($HTTP_POST_VARS['image_alt'],
"text"),
GetSQLValueString($HTTP_POST_VARS['image_order'], "int"),
GetSQLValueString($HTTP_POST_VARS['display'],"text"));
mysql_select_db($database_vb_conn, $vb_conn);
$Result1 = mysql_query($insertSQL, $vb_conn) or die(mysql_error());
if (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $HTTP_SERVER_VARS['QUERY_STRING']; }
if (isset($HTTP_POST_VARS['another']))
{ $nb= $HTTP_POST_VARS['page_id'];
$insertGoTo = "ins_pages.php?inb=$nb"; }
else { $insertGoTo = "issues_menu.php";}
**************************************************************************************************************************
header(sprintf("Location: %s", $insertGoTo));
*************************************here is the error
exit();}
ob_get_contents() ;
**************************************************************************************************************************
?>
<? ob_end_flush(); ?>
<?php echo "-------------"."<br>"; ?>
<html>
<head>
<title>Uploading</title> <body link="#FFFFFF" vlink="#FFFFFF"
alink="#FFFFFF"><br>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8"></head>
<link rel="stylesheet" href="../cp.css">
<body>
</body>
</html>
_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.
http://join.msn.com/?page=features/virus