English 中文(简体)
将页数与引起问题的PHP重新定位
原标题:Redirecting Pages with PHP causing problems

我有一页,链接到从“GET”美元获取数据并更新数据库的“php”网页。 之后,用户返回主页:

header("Location: http://localhost/");

事实是,这似乎在法典的神话部分“破裂”。 如果我去掉这一方向,数据库中的所有内容都会得到更新,但当我回去时,没有任何更新。

这是数据库更新代码,我使用一类地雷作为我的仪表板:

$conn->where( hash ,$data1[ hash ]);
$conn->update(TABLE_ITEMS,$newData1);

$conn->where( hash ,$data2[ hash ]);
$conn->update(TABLE_ITEMS,$newData2);

Notes:

- 网页上没有文字或对应材料,在<条码>上没有空间;? 标签

Order of Code:

  1. Data received from $_SESSION and $_GET
  2. Data processed and placed into arrays
  3. Data placed into mysql database
  4. header(); used to redirect page

Code

<?php
require_once( config.php );
import();

if ( isset ( $_GET[ g ] ) && isset ( $_SESSION[ itemA ] ) && isset ( $_SESSION[ itemB ] ) ) {
$itemA = $_SESSION[ gameA ];
$itemB = $_SESSION[ gameB ];

$newData1 = processData($itemA);
$newData2 = processData($itemB);

$conn->update(TABLE_ITEMS,$newData1);

$conn->update(TABLE_ITEMS,$newData2);

header( Location: http://localhost/ );

} else {
    header( Location: http://localhost/ );
}
最佳回答

我不知道为什么这样做了,但我却指出,如果我改变的话:

header("Location: http://localhost/");

为此:

header( Location: http://localhost/ );

一切都行之有效。

问题回答

如果你在产出以前的内容时派一名负责人,你就会犯错误,造成你的文字停止执行。 因此,如果标题高于更新,则可能根本不执行更新。 这取决于你是否看到这一错误。

<?
echo  yo ;
header( Location: .... ); // <-- error

Update(); // Never gets executed

The output doesn t have to be an echo. It can even be a single space before the opening <?.

如果不看到该法典的很多内容,它就难以确定,但我的猜测是,PHP的网页现在仍在紧接着。 我可能建议的是,改头版的网页(即你的主页)本身正在从事一些数据库工作,掩盖了原页所做的改动。

正如我所说的那样,在没有任何其他法典的情况下(或甚至对所涉数据或网站所做的任何细节),那就是一个荒谬的gues,但我说,这值得调查。

Try putting ob_start() at the top of the file. It sometimes helps. You can t output before calling header(). Show more code. It s to less of it to think what is wrong.





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

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 = ...

php return a specific row from query

Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...

Character Encodings in PHP and MySQL

Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...

Pagination Strategies for Complex (slow) Datasets

What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...

Averaging a total in mySQL

My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...

热门标签