标题('Location:')跳转被忽略了? [英] header('Location:') jump ignored?
问题描述
我看到一个让我感到困惑的问题。我能想到的唯一一件事就是我违反了一些我不知道的规则。
我有一些代码可以做一些处理,然后做一个
标题(''位置:...)成功跳转到页面A或者跳到页面B跳转到
这是代码:
if(mysql_query(''LOCK TABLES tableX WRITE'',$ link))
{
mysql_query ($ q,$ link); //存储记录
$ ID = mysql_insert_id($ link); //保存新ID
if(mysql_affected_rows($ link)== 1)
{
unlock_tables();
$ _SESSION [''ErrMsg''] =''新ID是''。 $ ID;
header(''Location:PageA.php'');
$ _SESSION [''ErrMsg'']。=''错误:忽略跳转' ';
}
其他//商店失败
{错误处理}
}
//第二次机会(用于调试)做正确的事情
header(''Location:PageA.php'');
$ _SESSION [' 'ErrMsg'']。=''它再次忽略了它!'';
//我们根本不应该到达这里 - 但我们做到了!
标题(''位置:PageB.php);
不幸的是,正如我从告诉我所知道的那样,
商店有效但是解释器忽略两个标题调用,它们将跳转到A并最终跳转到B。除非我更累,否则我知道,或者更无知,这没有意义。
任何一根稻草都感激地抓着。
玛格丽特
-
(要给我发邮件,请先将.not.invalid更改为.net。
对给您带来的不便表示歉意。)
I''m seeing a problem that has me flummoxed. The only thing I can
think of is that I''m violating some rule I don''t know about.
I have some code that does some processing and then does a
header(''Location: ...) jump to page A on success or falls through to
the jump to page B. This is the code:
if ( mysql_query( ''LOCK TABLES tableX WRITE'', $link ) )
{
mysql_query( $q, $link ) ; // store the record
$ID = mysql_insert_id( $link ) ; // save the new id
if ( mysql_affected_rows($link) == 1 )
{
unlock_tables() ;
$_SESSION[''ErrMsg''] = ''New ID is '' . $ID ;
header( ''Location: PageA.php'' ) ;
$_SESSION[''ErrMsg''] .= '' Error: ignored jump'' ;
}
else // the store failed
{ error handling }
}
// second chance (for debugging) to do the right thing
header( ''Location: PageA.php'' ) ;
$_SESSION[''ErrMsg''] .= '' and it ignored it AGAIN!'' ;
// and we shouldn''t get here at all -- but we do!
header( ''Location: PageB.php ) ;
Unfortunately, as I know from the telltales I stuff into session, the
store works but the interpreter ignores both header calls that would
jump to A and finally jumps to B instead. Unless I''m more tired than
I''m aware, or more ignorant, this doesn''t make sense.
Any straw gratefully clutched.
Margaret
--
(To mail me, please change .not.invalid to .net, first.
Apologies for the inconvenience.)
推荐答案
链接))
{
mysql_query(
link ) )
{
mysql_query(
q,
link); //存储记录
link ) ; // store the record
这篇关于标题('Location:')跳转被忽略了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!