查看: 1250|回复: 21
|
Php (header) function 不运行...
[复制链接]
|
|
$sql = "insert into job (position,location,details,d_start,d_end) values ('$position','$location','$des','$date1','$date2')";
$rs = mysql_query($sql, $link);
if($rs){
header( "Location: job_list.php" );
}
else{
echo $sql;
echo mysql_error();
?>
Error Message.
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\webcv\config.php:1) in C:\wamp\www\webcv\insert_process.php on line 27
我不知道为什么一直出现这问题。。。
我写错了什么??
之前还可以的...
但是现在不行了... 唉..
我能够insert.. 但是insert了我要跳去别的一面...
在跳别的一面时, 就出现这Error了..
说我的header有问题.....
有谁可以帮帮忙呢???
[ 本帖最后由 wcpon 于 7-11-2007 05:18 PM 编辑 ] |
|
|
|
|
|
|
|
发表于 8-11-2007 11:08 AM
|
显示全部楼层
header(); 之前有没有些什么输出? like echo ""; ....
空行或space这类的呢? |
|
|
|
|
|
|
|

楼主 |
发表于 9-11-2007 10:11 AM
|
显示全部楼层
原帖由 cacphy 于 8-11-2007 11:08 AM 发表 
header(); 之前有没有些什么输出? like echo ""; ....
空行或space这类的呢?
<?php
session_start();
include("config.php");
include("conn.php");
$position = $_POST['position'];
$location = $_POST['location'];
$des = $_POST['des'];
$date1 = $_POST['year1'].$_POST['month1'].$_POST['day1'];
$date2 = $_POST['year2'].$_POST['month2'].$_POST['day2'];
$sql = "insert into job (position,location,details,d_start,d_end) values ('$position','$location','$des','$date1','$date2')";
$rs = mysql_query($sql, $link);
if($rs)
{
header("Location:job_list.php");
}
else
{
echo $sql;
echo mysql_error();
?>
<html>
<body>
<script language=javascript>
alert('Error, Please input again.');
window.location.href="job_posting.php";
</script>
</body>
</html>
<?php }?>
我的code是这样的....
但是不知道哪里出问题....
跑这个error message出来...
Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\webcv\config.php:1) in C:\wamp\www\webcv\insert_process.php on line 27
唉.... |
|
|
|
|
|
|
|
发表于 9-11-2007 10:47 AM
|
显示全部楼层
include("config.php");
include("conn.php");
应该是这2行里面已经有output的关系吧.. |
|
|
|
|
|
|
|

楼主 |
发表于 9-11-2007 11:20 AM
|
显示全部楼层
原帖由 jasonmun 于 9-11-2007 10:47 AM 发表 
include("config.php");
include("conn.php");
应该是这2行里面已经有output的关系吧..
我的 config.php
<?php
define('SQL_HOST', 'localhost');
define('SQL_USER', 'root');
define('SQL_PASS', '');
?>
和
我的 conn.php
<?php
$link = mysql_connect(SQL_HOST,SQL_USER,SQL_PASS)
or die ('Could not connect to the databases.'.mysql_error());
//Select Database
$select= mysql_select_db ("testing")
or die ("Could not select database.");
?>
有问题吗?
[ 本帖最后由 wcpon 于 9-11-2007 11:21 AM 编辑 ] |
|
|
|
|
|
|
|
发表于 9-11-2007 01:16 PM
|
显示全部楼层
请查看你每一页的最上一行有没有空行?Example of below:
<--这里不可以空行哦!--->
<?php
?> |
|
|
|
|
|
|
|

楼主 |
发表于 9-11-2007 05:41 PM
|
显示全部楼层
原帖由 cacphy 于 9-11-2007 01:16 PM 发表 
请查看你每一页的最上一行有没有空行?Example of below:
我没有空行哦...
之前我的电脑可以的...
之后现在我用新电脑... 就不能了...
不知道什么事情...
唉... 有什么办法可以解决呢?!?? |
|
|
|
|
|
|
|
发表于 10-11-2007 01:28 AM
|
显示全部楼层
回复 #7 wcpon 的帖子
header 不行就用javascript 吧.
把header("Location:job_list.php");换成
echo "<script>";
echo "location.href='job_list.php';";
echo "</script>"; |
|
|
|
|
|
|
|
发表于 10-11-2007 02:04 AM
|
显示全部楼层
你应该是用localhost 的吧
试试把 buffer 打开 |
|
|
|
|
|
|
|
发表于 10-11-2007 02:26 AM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 11-11-2007 02:37 AM
|
显示全部楼层
header("Location:job_list.php");
第一:
please leave a space in between Location: and job_list.php
Location: job_list.php
第二:
make sure there are not space before <?
and after ?>
no space is allowed
第三:
check your sql query , make sure it have no error returned, which will echo error to screen and cause your header redirection not functioning |
|
|
|
|
|
|
|

楼主 |
发表于 12-11-2007 09:42 AM
|
显示全部楼层
原帖由 vampcheah 于 10-11-2007 02:04 AM 发表 
你应该是用localhost 的吧
试试把 buffer 打开
在哪里打开buffer?
我是用wamp server的..... |
|
|
|
|
|
|
|

楼主 |
发表于 12-11-2007 11:38 AM
|
显示全部楼层
原帖由 gBoy 于 11-11-2007 02:37 AM 发表 
header("Location:job_list.php" ;
第一:
please leave a space in between Location: and job_list.php
Location: job_list.php
第二:
make sure there are not space before
no space is allowed ...
所有我都检查了...
没有问题...
还是不能... 唉.... |
|
|
|
|
|
|
|

楼主 |
发表于 12-11-2007 11:39 AM
|
显示全部楼层
|
|
|
|
|
|
|
发表于 12-11-2007 11:53 AM
|
显示全部楼层
原帖由 wcpon 于 12-11-2007 09:42 AM 发表 
在哪里打开buffer?
我是用wamp server的..... 上几楼的link 里有教,在php.ini 里。 |
|
|
|
|
|
|
|

楼主 |
发表于 12-11-2007 12:14 PM
|
显示全部楼层
原帖由 vampcheah 于 12-11-2007 11:53 AM 发表 
上几楼的link 里有教,在php.ini 里。
不知道你可以给我那个link吗??
我不知道哪一个主题... 太多了..
谢谢.... |
|
|
|
|
|
|
|

楼主 |
发表于 12-11-2007 01:13 PM
|
显示全部楼层
我发现问题出在哪里了...
是我的..
config.php和conn.php有少许问题...
我能不能这样放??
<title>XXXXXX</title><?php
$link = mysql_connect(SQL_HOST,SQL_USER,SQL_PASS)
or die ('Could not connect to the databases.'.mysql_error());
//Select Database
$select= mysql_select_db ("db01")
or die ("Could not select database.");
?>
我撤掉那个title...
我的header就能跑了...
为什么呢??
如果我还要那个title,我该怎样做呢?? |
|
|
|
|
|
|
|
发表于 12-11-2007 04:58 PM
|
显示全部楼层
回复 #17 wcpon 的帖子
你然到不知道<TITLE>也算是Output吗?
我建议你Process 的page 一页, 有output的又一页. |
|
|
|
|
|
|
|
发表于 12-11-2007 05:54 PM
|
显示全部楼层
原帖由 cacphy 于 12-11-2007 04:58 PM 发表 
你然到不知道也算是Output吗?
我建议你Process 的page 一页, 有output的又一页. 可以直接把所有process 都搬到<html> 上面。 分页常常造成混乱 (对新手)。 |
|
|
|
|
|
|
|
发表于 13-11-2007 01:20 PM
|
显示全部楼层
原帖由 wcpon 于 12-11-2007 01:13 PM 发表 
我发现问题出在哪里了...
是我的..
config.php和conn.php有少许问题...
我能不能这样放??
XXXXXX
我撤掉那个title...
我的header就能跑了...
为什么呢??
如果我还要那个title,我该怎样做呢??
这样应该可以吧.
<?php
echo "<html><title>XXXXXX</title>";
$link = mysql_connect(SQL_HOST,SQL_USER,SQL_PASS)
or die ('Could not connect to the databases.'.mysql_error());
//Select Database
$select= mysql_select_db ("db01")
or die ("Could not select database.");
echo "</html>";
?> |
|
|
|
|
|
|
| |
本周最热论坛帖子
|