English 中文(简体)
我是否需要修改我的“蓝盔”档案? 未从事远程服务器工作的主管职能
原标题:Do I need to modify my Bluehost php.ini file? Header function not working on remote server

下面使用的一组代码,是使用一个当地、而不是我的“蓝盔”服务器进行直接工程:

if ($_POST[ submit ]== No )
{
    $url = Location: index.php?id= .$id. &page= .$page;
    header($url);
    exit;
}

当服务器进入这一编码系统时,绝对不会发生。 没有错误,没有警告,只是一页空白。 我的表格中转头页,除将用户重新引向相关网页外,还应做任何事情。

I m pretty dang positive it has nothing to do with the common problem of including HTML before the redirect (since it works locally). Therefore I suspect it has something to do with differences between my php.ini files. I ve pulled up PHPinfo() for both servers, and my local server has a module named mod_headers while my Bluehost server has none. I think this potentially could be the problem, although normally my Bluehost has no problems using header redirects, except in this one instance.

因此,我怀疑这个问题与我的手法有关,但我不知道什么。

What makes this problem even stranger is that there are other blocks of code which work just fine, for instance

if(!empty($_POST[ id ]))
{
    $id = htmlentities(strip_tags($_POST[ id ]));
    $sql = "UPDATE entries SET title=?, entry=? WHERE id=? LIMIT 1";
    $stmt = $db->prepare($sql);
    $stmt->execute(array($title,$entry,$id));
    $stmt->closeCursor();
    $url=  Location: ../index.php?id= .$id. &page= .$page;
    header($url);
    exit;
}   

works just great.

最佳回答

我有同样的问题,那就是,它在XAMPP上工作,但不是在蓝色堡或1&上工作。

PHP documentation says there should be no output before calling the header function. http://php.net/manual/en/function.header.php

In my case there was a space before the opening <?PHP which made the header function not work.

这将有助于解决这一问题。

The quesiton remains though: why does it work on XAMPP and not on the servers of bluehost, 1&1, etc? (since I use firefox for both tests - it is definitely not a browser issue)

问题回答

我只是有这个问题。 我认识到,我正在使用一个编辑,在档案一开始便插入一个管理局。 多数编辑几乎看不见这种BOM特性,但会停止PHP的头盔射击,因为它确实算是民意。 这里有关管理局特性的更多信息:

I was using notepad++ and was able to disable this BOM by using these directions:

  1. Go to Settings > Preferences > New Document/Default Directory
  2. Changed Encoding to UTF-8 without BOM

I faced the same problem when running moving my Wordpress blog to Bluehost.
The solution was to change output_buffering option in php.ini
Look what at my config along with the explanation of this option:

; Output buffering allows you to send header lines (including cookies) even
; after you send body content, at the price of slowing PHP s output layer a
; bit. You can enable output buffering during runtime by calling the output
; buffering functions. You can also enable output buffering for all files by
; setting this directive to On. If you wish to limit the size of the buffer
; to a certain size - you can use a maximum number of bytes instead of On , as
; a value for this directive (e.g., output_buffering=4096). output_buffering = 4096





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签