Jump to content

Recommended Posts

Hello.

 

I searched google and found that the headers already sent problem error is returned if theres a white space. Still, on my script there's nothing on the first line.

 

<?php

ob_start();
$inTwoMonths = 60 * 60 * 24 * 60 + time();
setcookie('lastVisit', date("Y-m-d G:m:s"), $inTwoMonths);
ob_end_flush();

//show form
if (!isset($_POST['sub'])){
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<head><title>Ajuntamento do Pandalho</title>

 

This are the first lines of my script.

 

Why do I keep getting "Warning: Cannot modify header information - headers already sent by (output started at D:\wamp\www\pandalho\index.php:1) in D:\wamp\www\testing\index.php on line 5"

 

Thank you.

 

Link to comment
https://forums.phpfreaks.com/topic/81044-solved-setcookie-headers/
Share on other sites

The cause of the error is on line 1 in D:\wamp\www\pandalho\index.php. The error was returned from D:\wamp\www\testing\index.php on line 5

 

What is on line 1 in D:\wamp\www\pandalho\index.php? <<< That is the file that is causing the error.

Warning: Cannot modify header information - headers already sent by (output started at D:\wamp\www\pandalho\index.php:1) in D:\wamp\www\pandalho\index.php on line 5

 

This is the right error. Sorry.

 

In the first line there is a single <?php tag without any spaces!

 

Thank you!

How was the file created? Your text editor maybe the cause. Try creating it with just notepad.

 

Note: When saving with notepad make sure you go to File > Save As... and that the File Type pull down menu is set to All Files and the Encoding is set to ANSI.

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.