相关疑难解决方法(0)

无法在PHP中修改标题信息警告消息?

我的index.php页面代码是 -

<?php

if(!$_COOKIE['authorized'] == 1) {
header("Location: login.php");
}

?>


<!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>
<title>My Photo Website</title>
<script src="js/jquery-1.2.6.pack.js" type="text/javascript"></script>
<script src="js/jquery.lightbox-0.5.pack.js" type="text/javascript"></script>
<script src="js/myscript.js" type="text/javascript"></script>
<link rel="stylesheet" href="css/default.css" />
<link rel="stylesheet" href="css/jquery.lightbox-0.5.css" />


</head>
<body>
<form method="post" action="changePhotoTitle.php">
<div id="container">
<h1>My Photos <small>click on the text to change the title.</small></h1>
<a href="login.php?logout=1" id="logout">logout</a>

<div id="main">

<?php require 'getPhotos.php'; ?>

<div id="response" class="hidden" />
</div><!-- end main-->

</div><!-- end …
Run Code Online (Sandbox Code Playgroud)

php warnings http-headers

1
推荐指数
1
解决办法
2277
查看次数

"警告:session_start()[function.session-start]:无法发送会话cookie - 已经发送的标头"在文件中首先调用session_start()时

<?php
   session_start();
   $_SESSION['start']=1;

   echo $_SESSION['start'];
?>
Run Code Online (Sandbox Code Playgroud)

FF输出:

警告:session_start()[function.session-start]:无法发送会话cookie - 已在第10行的.../test.php中发送的输出(输出从.../test.php:1开始)

警告:session_start()[function.session-start]:无法发送会话缓存限制器 - 已经在第10行的.../test.php中发送的输出(在.../test.php:1处开始输出)

php session utf-8

1
推荐指数
1
解决办法
9552
查看次数

session_start() [function.session-start] 的问题:

这是错误代码:

Cannot send session cookie - headers already sent by (output started at
C:\xampp\htdocs\log\New folder (4)\New folder (2)\iskono\forum.php:5) in 
C:\xampp\htdocs\log\New folder (4)\New folder (2)\iskono\forum.php on line 244

Warning: session_start() [function.session-start]: Cannot send session cache limiter - 
headers already sent (output started at C:\xampp\htdocs\log\New folder (4)\New folder 
(2)\iskono\forum.php:5) in C:\xampp\htdocs\log\New folder (4)\New folder 
(2)\iskono\forum.php on line 244 
Run Code Online (Sandbox Code Playgroud)

第244行是需要的代码

<? require("forum/index.php"); ?>
Run Code Online (Sandbox Code Playgroud)

如何解决这个错误?

php

1
推荐指数
1
解决办法
5095
查看次数

标头已通过刷新功能发送?

我收到一个有趣的错误,表示标题已经通过ob_end_flush()发送; 当我运行以下代码时.这是我得到的确切错误

警告:不能更改头信息 - 头已经发出(输出开始/export/home/ua/games/gamescripts/login_backend2.php:47)在/export/home/ua/games/gamescripts/login_backend2.php在线57应该已经重定向到现在

第47行是ob_end_flush();

编辑:对不起我粘贴我的代码时有点粗心.我现在已经以正确的格式安排了它.

<?php

include_once('Services_JSON.php');
include 'connect.php';
include_once('functions.php');
error_reporting(E_ALL | E_WARNING | E_NOTICE);
ini_set('display_errors', TRUE);


$json = new Services_JSON();  
$username=  $_POST["username"];  
$password = $_POST["password"];  

$check=0;  
$query="SELECT * FROM `game_users` WHERE `username` LIKE  '$username'";  
$result = mysql_query($query)  
or  
 die("<br>Query Error: ".mysql_error());  

while($row = mysql_fetch_row($result))  
{  

    $user = $row[2];  
    $pass = $row[3];  
    $name = $row[1];  

        if($username == $user )  
        {  

            if($password == $pass)  
            {    
                              $Day = 86400 + time(); // 1 Day    
                              $name= "name";  
                              $user= "user";  
                              $pass= "password"; …
Run Code Online (Sandbox Code Playgroud)

php mysql cookies header flush

1
推荐指数
1
解决办法
5802
查看次数

文件上传后"标头已发送"错误

我上传文件后发生了这种错误.但是我的localhost没有任何错误.这有什么错误?如何解决这个问题?

警告:session_start()[function.session-start]:无法发送会话cookie - 在/ home/lahiruca/public_html中已经发送的标题(在/home/lahiruca/public_html/events/includes/links.php:1中开始输出)第1行的/events/includes/header.php

(来自评论)

<?php session_start();?> 
<div class="header"> 
<div class="logo"></div> 
<div class="right_header"> 
<div class="top_right_header"> 
  <ul> <?php if(isset($_SESSION['userid'])){ ?> 
Run Code Online (Sandbox Code Playgroud)

php

1
推荐指数
1
解决办法
240
查看次数

带有绝对URL的cURL get_data($ url)

我正在使用此代码使用cURL获取数据

$url='http://example.com/'; //URL to get content from..
print_r(get_data($url)); //Dumps the content

/* Gets the data from a URL */
function get_data($url)
{
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
Run Code Online (Sandbox Code Playgroud)

但是,此代码返回具有相对URL的数据.如何通过绝对URL获取此相对URL和打印?可能与preg_replace ..但如何?

php curl

1
推荐指数
1
解决办法
7186
查看次数

避免在php页面上重新发送表单

当我刷新php页面时,有没有办法避免重新处理表单?我想在刷新带有插入功能的php文件的链接时阻止重新发送表单.例如,我正在处理用户在每页顶部写的一系列笔记,以获得新笔记.除了明显创建一个带有头功能的单独的php文件之外还有另外一种方法吗?

php

1
推荐指数
1
解决办法
6304
查看次数

在头函数中传递url中的变量

我试图在标头函数中传递URL中的变量.我知道index2.php?ID=<?=$objResult["ID"];?>如果它不在标题函数中,我可以这样做 .但是,如果我尝试在头函数中执行此操作,则整个脚本崩溃.我也试过这个:

header("Refresh: 5;url=index2.php?ID=".$objResult["ID"]."");
Run Code Online (Sandbox Code Playgroud)

但是这会产生以下错误:

警告:无法修改标题信息 - 已在第33行的/var/www/Mail/index.php中发送的标题(在/var/www/Mail/index.php:25处开始输出)

(第33行是标题行)

我的整个代码是这样的:

<?php
if($_POST)
{
    mysql_connect('localhost','root','root');
    mysql_select_db('NAW') or die (mysql_error());

    $Naam              =    $_POST['naam'];
    $Email             =    $_POST['email'];
    $Soort             =    $_POST['soort'];

    $sql = mysql_query("INSERT INTO Klant (Naam, Email, Soort) VALUES ('".$Naam."', '".$Email."', '".$Soort."')") or die (mysql_error());

    if ($sql === false) {

        die (mysql_error());

    }

    else {

        echo ''.$Naam.' is in de database toegevoegd.<br><br>';

    }

    $strSQL         = ("SELECT * FROM Klant WHERE Naam='".$Naam."'");
    $objQuery       = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
    $objResult      = …
Run Code Online (Sandbox Code Playgroud)

php variables url header

1
推荐指数
1
解决办法
1265
查看次数

CakePHP:重定向不工作

我的控制器中有以下代码:

class ContactsController extends AppController {
    public $helpers = array('Html', 'Form', 'Session');
    public $components = array('Session');

    public function index() {
        $this->set('contacts', $this->Contact->find('all'));
    }

    public function view($id) {
        if (!$id) {
            throw new NotFoundException(__('Invalid contact'));
        }

        $contact = $this->Contact->findById($id);
        if (!$contact) {
            throw new NotFoundException(__('Invalid contact'));
        }
        $this->set('contact', $contact);
    }

    public function add() {                 
        if ($this->request->is('post')) {
            $this->Contact->create();
            if ($this->Contact->save($this->request->data)) {
                $this->Session->setFlash('Your contact has been saved.');
                $this->redirect(array('action' => 'index'));
            } else {
                $this->Session->setFlash('Unable to add your contact.');
            }
        }
    }
} …
Run Code Online (Sandbox Code Playgroud)

cakephp

1
推荐指数
2
解决办法
6858
查看次数

session_start():无法发送会话缓存限制器-标头&gt;已发送

我知道这个问题可能会被标记为重复,但是我从任何重复的帖子中都找不到答案,因此我决定将其张贴在自己的位置。

我有一个带有会话的页面。在完成所有任务之后,有一个链接到此控制器的按钮称为Profileresult.php,但即使我没有代码,但令我惊讶的是我遇到了此错误。

这是错误。

遇到PHP错误

严重程度:警告

消息:session_start():无法发送会话缓存限制器-标头已发送(输出从/home3/oep2732/public_html/knowyourscore/application/controllers/Profileresult.php:1开始)

文件名:Session / Session.php

行号:140

回溯:

文件:/home3/oep2732/public_html/knowyourscore/index.php行:315功能:require_once

我创建了一个名为Profileresult.php的控制器

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Profileresult extends CI_Controller {


    public function index()
    {
    }

}

?>
Run Code Online (Sandbox Code Playgroud)

session codeigniter

1
推荐指数
1
解决办法
6689
查看次数

标签 统计

php ×8

header ×2

session ×2

cakephp ×1

codeigniter ×1

cookies ×1

curl ×1

flush ×1

http-headers ×1

mysql ×1

url ×1

utf-8 ×1

variables ×1

warnings ×1