Jump to content

Recommended Posts

I have a form which posts to ranges_process.php (shown below)

 

I have an error;

 

Warning: Cannot modify header information - headers already sent by (output started at urlhere/ranges_process.php:3) in sameurlhere/ranges_process.php on line 37

 

Ive checked and as far as I can see, im not echoing or printing anything. What could be causing this warning?

 

 

 

<?php session_start();?>


<?php
$user_id = $_SESSION['user_id'];


if(isset($_POST['processForm']))
{
$yards = $_POST['yards'];
$club = $_POST['club'];
$date = $_POST['date'];
$competition = $_POST['location'];


if (empty($date)) {$a= "<br />You haven't entered a date"; $errors_found = true;}
if (!is_numeric($yards)) {$b= "<br />You haven't entered a distance!"; $errors_found = true;}
if (empty($club)) {$c= "<br/>You haven't selected a club!"; $errors_found = true;}
if (empty($competition)) {$d= "<br />You haven't entered a location"; $errors_found = true;}

if (!$errors_found) {
$date = str_replace("-","",$date);
$year =substr($date,0,4);


//CONNECTION HERE
$connect_solning = mysql_connect($hostname_connect, $username_connect, $password_connect) or trigger_error(mysql_error(),E_USER_ERROR);
@mysql_select_db($database_connect) or die (mysql_error());

$sql = "INSERT INTO TABLENAMEHERE (user_id, yard, club, date, year, competition) VALUES ('$user_id', '$yards', '$club', '$date', '$year', '$competition')";
mysql_query($sql);

$e= '<br/><br/>A distance, has now been added.';
}};

header("Location: http://URLHERE/beta/ranges2.php?a=$a&b=$b&c=$c&d=$d&e=$e"); // line 37

//RETURN TO ORIGINAL LOCATION...

?>

Link to comment
https://forums.phpfreaks.com/topic/274588-my-header-refresh-is-not-working/
Share on other sites

This tells you exactly where you started sending output -- The :3 here means LINE 3 of that file.

output started at urlhere/ranges_process.php:3

 

If this is your actual code, then this is your problem

<?php session_start();?>


<?php
$user_id = $_SESSION['user_id'];

Everything outside of PHP tags -- including those two blank lines -- is sent to the browser as content. There is no reason to break out of and back into PHP here.

 

I have no idea why but when I changed my URL, everything worked fine...

If should NOT make any difference to that particular error. And FYI, the specs say that the URL in the Location header must be absolute (so you had it right the first time).

 

 

 

<?php session_start();?>


<?php
$user_id = $_SESSION['user_id'];


if(isset($_POST['processForm']))
{
$yards = $_POST['yards'];
$club = $_POST['club'];
$date = $_POST['date'];
$competition = $_POST['location'];


if (empty($date)) {$a= "<br />You haven't entered a date"; $errors_found = true;}
if (!is_numeric($yards)) {$b= "<br />You haven't entered a distance!"; $errors_found = true;}
if (empty($club)) {$c= "<br/>You haven't selected a club!"; $errors_found = true;}
if (empty($competition)) {$d= "<br />You haven't entered a location"; $errors_found = true;}

 

 

 

CTRL + Q to Enable/Disable GoPhoto.it

besides that you need to do something about the lay out it is not handy for other pprogrammers including yourself to read messy code

first of all you can do this

<?php
if($x!=$y): echo"x is not y";endif;
?>

and this

<?php
if($x!=$y)
TAB{
TABTAB echo"x is not y";
TABTAB if($x>$Y)
TABTAB {
TABTABTAB echo"x is more than y"
TABTAB }
TABTAB else
TABTAB {
TABTABTAB echo"y is probebly equal or bigger than x";
TABTAB }
TAB}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.