查看: 859|回复: 15
|
php code error
[复制链接]
|
|
当我register后,用register乐得id和password来login,出现了error,想问有谁知道是什么问题,请帮帮忙
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\travel\index.php:12) in C:\wamp\www\travel\mode\user.tpl on line 44
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\travel\index.php:12) in C:\wamp\www\travel\mode\user.tpl on line 45
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\travel\index.php:12) in C:\wamp\www\travel\mode\user.tpl on line 46
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\travel\index.php:12) in C:\wamp\www\travel\mode\user.tpl on line 47
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\travel\index.php:12) in C:\wamp\www\travel\mode\user.tpl on line 58
[ 本帖最后由 我是你的分身 于 7-2-2007 08:34 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 7-2-2007 08:58 AM
|
显示全部楼层
原帖由 我是你的分身 于 7-2-2007 08:31 AM 发表
当我register后,用register乐得id和password来login,出现了error,想问有谁知道是什么问题,请帮帮忙
Warning: Cannot modify header information - headers already sent by (output started ...
echo或printr不应该出现在header之前。 |
|
|
|
|
|
|
|

楼主 |
发表于 7-2-2007 10:07 AM
|
显示全部楼层
原帖由 hui_wooi 于 7-2-2007 08:58 AM 发表
echo或printr不应该出现在header之前。
可是我的header之前,没有放echo或printr |
|
|
|
|
|
|
|
发表于 7-2-2007 10:10 AM
|
显示全部楼层
看看你C:\wamp\www\travel\mode\user.tpl的line 44,45,46等等。 |
|
|
|
|
|
|
|

楼主 |
发表于 7-2-2007 10:15 AM
|
显示全部楼层
原帖由 hui_wooi 于 7-2-2007 10:10 AM 发表
看看你C:\wamp\www\travel\mode\user.tpl的line 44,45,46等等。
while($logininfo = mysql_fetch_array($login))
{
$hit="true";
//Set the cookie
setcookie('user',$logininfo[MemberName]);
setcookie('password',$logininfo[MemberPwd]);
setcookie('id',$logininfo[MemberID]);
setcookie('type','User');
$login = mysql_query("SELECT * FROM agent WHERE AgentID = '$logininfo[MemberID]'");
//check is it the agent
if($logininfo = mysql_fetch_array($login)){
//if agent then set the type to agent
setcookie('type','Agent');
}
}
if($hit=="true"||$_COOKIE['user'] != ""){
header('Location:'.$usr_url.'?c=main');
}
else
{
echo "Username and Password do not match,Please try again.";
require('templates/user/login.tpl');
}
}
else{
require('templates/user/login.tpl');
}
}
function logout(){
//set all cookie to null
setcookie('user','');
setcookie('password','');
setcookie('id','');
setcookie('type','');
header('Location:'.$usr_url.'?c=main');
}
function main(){
require('templates/user/main.tpl');
}
红色的字是有error的line |
|
|
|
|
|
|
|
发表于 7-2-2007 06:58 PM
|
显示全部楼层
你run你那个有问题的PHP file时,那些出现在你所paste 出来的 warning之前的字,都不应该出现,即setcookie() 和 header()之前不可以有任何html output
[ 本帖最后由 hui_yang 于 7-2-2007 07:00 PM 编辑 ] |
|
|
|
|
|
|
|

楼主 |
发表于 7-2-2007 11:00 PM
|
显示全部楼层
原帖由 hui_yang 于 7-2-2007 06:58 PM 发表
你run你那个有问题的PHP file时,那些出现在你所paste 出来的 warning之前的字,都不应该出现,即setcookie() 和 header()之前不可以有任何html output
不明白
可以解释多点吗 |
|
|
|
|
|
|
|
发表于 8-2-2007 02:13 AM
|
显示全部楼层
原帖由 我是你的分身 于 7-2-2007 11:00 PM 发表
不明白
可以解释多点吗
看看你的 php 文件开端前几段有没有空行? 空格? 用 backspace 清除掉.
[ 本帖最后由 goatstudio 于 8-2-2007 02:15 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 8-2-2007 09:56 AM
|
显示全部楼层
回答我
你有没有 放这样东西?
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"/>
ok, 这个东西只能放/用一个。。。如果你是用 header 在 php 的楼下,那么是无法再用的,因为你已经 declare CONTENT='text/html'
无法改
希望这能帮到你 ^^
因为那个 message 已经告诉你无法 modify header 因为你有 declare 过了 |
|
|
|
|
|
|
|

楼主 |
发表于 8-2-2007 02:58 PM
|
显示全部楼层
谢谢楼上两位
不过还是不是很明白
这是我的index.php,想问下是不是那里出错了
<?php
require 'libs/Smarty.class.php';
require('config.php');
?>
<html>
<head>
<meta http-equiv="Content-Type" c>
<title>MalaysiaTravel.com</title>
<!-- inclde the css style -->
<link rel="stylesheet" type="text/css" href="libs/stylesheet.css">
<SCRIPT LANGUAGE="JavaScript" SRC="libs/CalendarPopup.js"></SCRIPT>
</head>
<body marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0">
<!-- header //-->
<?php
require('templates/header.tpl');
?>
<!-- header_eof //-->
<!-- body //-->
<center>
<!-- Navigation bar //-->
<table border="0" width="800" cellspacing="0" cellpadding="1">
<tr class="headerNavigation">
<td class="headerNavigation" align=center>
<a class="toolslink" href="<?php echo $usr_url."?c=Main" ?>">
<span style="text-decoration: none">
<nobr>Main Page</nobr></span></a>
|
<a class="toolslink" href="<?php echo $usr_url."?c=shwTC" ?>">
<span style="text-decoration: none">
<nobr>Terms & Conditions</nobr></span></a>
|
<a class="toolslink" href="mailto:abc@yahoo.com">
<span style="text-decoration: none">
<nobr>Contact Us</nobr></span></a>
</td>
</tr>
</table>
<table id="main" border="0" width="800px" cellspacing="0" cellpadding="0">
<tr>
<!-- if login already then display function menu ,else display simple menu -->
<?php
echo "<td width='150' valign='top' cellspacing='0' cellpadding='0'>";
if (isset($_COOKIE['user'])) {
require('templates/user/menu.tpl'); //After Login
}else{
require('templates/menu.tpl'); //Before Login
}
echo "</td>";
?>
<td valign="top" align="center">
<!-- inclde user main file -->
<?php
require('mode/user.tpl');
?>
<br>
<br>
</td>
<td valign="top" align="right" width="80">
<!-- inclde the promotion & currency convertor in the right hand side -->
<?php require('templates/user/promotion.tpl'); ?>
<br>
<br>
</td>
</tr>
</table>
<!-- body_eof //-->
<!-- footer //-->
<?php require('templates/footer.tpl'); ?>
<!-- footer_eof //-->
<br>
</body>
</html>
|
|
|
|
|
|
|
|

楼主 |
发表于 8-2-2007 03:00 PM
|
显示全部楼层
原帖由 goatstudio 于 8-2-2007 02:13 AM 发表
看看你的 php 文件开端前几段有没有空行? 空格? 用 backspace 清除掉.
php 文件开端前几段没有空行 |
|
|
|
|
|
|
|

楼主 |
发表于 8-2-2007 03:00 PM
|
显示全部楼层
原帖由 cupid25 于 8-2-2007 09:56 AM 发表
回答我
你有没有 放这样东西?
<META HTTP-EQUIV="Content-Type" C/>
ok, 这个东西只能放/用一个。。。如果你是用 header 在 php 的楼下, ...
我在#10有放code,可以看看吗 |
|
|
|
|
|
|
|
发表于 8-2-2007 04:31 PM
|
显示全部楼层
原帖由 我是你的分身 于 8-2-2007 03:00 PM 发表
我在#10有放code,可以看看吗
恩
试试看 remove <meta http-equiv="Content-Type" c>
然后 run ^^
你的 coding 好乱
[ 本帖最后由 cupid25 于 8-2-2007 04:45 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 9-2-2007 12:25 AM
|
显示全部楼层
原帖由 我是你的分身 于 8-2-2007 03:00 PM 发表
php 文件开端前几段没有空行
你的 code 很乱. 问题出在你把你的 user.tpl 放在 index.php 的中间.
你 php 的开头已经有 html tag, 如 <body>, <head> 一般的 html.
然而你在中间加入的 user.tpl,
<!-- inclde user main file -->
<?php
require('mode/user.tpl');
?>
里面有个用 header 来 redirect 的 code. 这就是 问题的所在.
用 header 来 redirect 的话, 你的之前的 code 不能有 html output.
你应该想办法重新设计你的 structure, 把 redirect 的 code 放在 html output 之前. |
|
|
|
|
|
|
|

楼主 |
发表于 9-2-2007 03:40 AM
|
显示全部楼层
谢谢楼上几位
已经可以了
想要问下,我用wamp5,那个server on9 or off9要怎样用?是ftp来的吗? |
|
|
|
|
|
|
|
发表于 9-2-2007 09:41 AM
|
显示全部楼层
原帖由 goatstudio 于 9-2-2007 12:25 AM 发表
你的 code 很乱. 问题出在你把你的 user.tpl 放在 index.php 的中间.
你 php 的开头已经有 html tag, 如 <body>, <head> 一般的 html.
然而你在中间加入的 user.tpl,
<!-- incl ...
是啊是啊。。。你不说我也忘记了。。。。当初我弄那些 resample 照片 size 面对过
哈哈哈
但 header 的缺很好用但不错用 |
|
|
|
|
|
|
| |
本周最热论坛帖子
|