可能重复:
PHP 已发送的标头
昨天我终于拿到了我的第一本 Mac Book。我喜欢它,但有一个问题真的困扰着我。出于某种原因,我从 Windows 笔记本电脑转移的项目无法正常工作。XAMPP 启动,我转到 localhost/CI_BUHZ 并且登录页面按预期工作,我输入我的凭据并按 Enter,但由于某种原因,整个事情都卡在了我的登录控制器中的 validate_credentials 函数上。它没有给我任何错误,只有 2 个警告 - 包括在下面
我想指出:*这个项目在我转移它的旧 Windows 笔记本电脑上完美运行。*据我所知,Mod Rewrite 已开启——如果我的其他控制器方法调用(例如 CI_PROJECT/Login 和 CI_PROJECT/Feeds/Home)正常工作?*即使我删除了 validate_credentials 函数并仅使用以下内容重新创建它:
function validate_credentials()
{
redirect('site/home');
}
它仍然不会从我的 Mac 上的登录 -> 站点/主页。
这是原始的验证凭据功能:
function validate_credentials()
{
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query) // if the user's credentials validated...
{
$uid = $this->membership_model->grab_uid();
$data = array(
'username' => $this->input->post('username'),
'uid' => $uid,
'is_logged_in' => true
);
$this->session->set_userdata($data);
redirect('site/home');
}
else // incorrect username or password
{
$this->index();
}
}
这是.htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /CI_BUHZ/
#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#When your application folder isn't in the system folder
#This snippet prevents user access to the application folder
#Submitted by: Fabdrol
#Rename 'application' to your applications folder name.
RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]
#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
<IfModule !mod_rewrite.c>
# If we don't have mod_rewrite installed, all 404's
# can be sent to index.php, and everything works as normal.
# Submitted by: ElliotHaughin
ErrorDocument 404 /index.php
</IfModule>
这是它抱怨的 img_model (即使被调用的函数根本不需要这个模型:
<?php
class Image_model extends CI_Model {
function get_images ($album_id, $uid){
$album_id =(int)$album_id;
$q = $this->db->query("SELECT image_id, album_id_fk, timestamp, ext, uid_fk FROM images WHERE album_id_fk = $album_id AND uid_fk = $uid");
if($q->num_rows() > 0) {
foreach($q->result() as $row) {
$data[] = $row;
}
return $data;
}
}
function image_check($image_id , $uid_fk){
$image_id = (int)$image_id;
$query = mysql_query("SELECT COUNT(image_id) FROM images WHERE image_id = $image_id AND $uid_fk");
return (mysql_result($query, 0)==1) ? true : false;
}
function delete_image($uid_fk, $image_id){
$image_id =(int)$image_id;
$image_query = mysql_query("SELECT album_id_fk , ext , uid_fk FROM images WHERE image_id = $image_id AND uid_fk = $uid_fk");
$image_result = mysql_fetch_assoc($image_query);
$album_id = $image_result['album_id_fk'];
$ext = $image_result['ext'];
$uid = $image_result['uid_fk'];
unlink('uploads/'.$uid.'_'.$album_id.'_'.$image_id.'.'.$ext);
unlink('uploads/thumbs/'.$uid.'_'.$album_id.'_'.$image_id.'.'.$ext);
mysql_query("DELETE FROM images WHERE image_id = $image_id AND uid_fk = $uid_fk");
}
}
?>
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/CI_BUHZ/application/models/image_model.php:2)
Filename: libraries/Session.php
Line Number: 672
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/CI_BUHZ/application/models/image_model.php:2)
Filename: helpers/url_helper.php
Line Number: 546