可能重复:
PHP 已发送的标头
我正在使用 Joomla 2.5 我在 joomla 之外开发了一个小表单,并希望使用 Joomla 身份验证来限制对它的访问。
我创建了三个文件:
auth.php(它存在于 joomla 根目录中)
<?php
define( '_JEXEC',1);
define('JPATH_BASE', dirname(__FILE__));
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
/* Create the Application */
$mainframe =& JFactory::getApplication('site');
/* Make sure we are logged in at all. */
if (JFactory::getUser()->id == 0)
die("Access denied: login required.");
?>
其次是connect-db.php
<?php
$server = 'xxxxxxxxx';
$user = 'xxxxxxxx';
$pass = 'xxxxxxxxxxxx';
$db = 'xxxxxxxxxxx';
// Connect to Database
$connection = mysql_connect($server, $user, $pass)
or die ("Could not connect to server ... \n" . mysql_error ());
mysql_select_db($db)
or die ("Could not connect to database ... \n" . mysql_error ());
?>
第三是 list_names.php 它在文件夹“list”中
<?php
// connect to the database
include('../auth.php');
include('connect-db.php');
// get results from database
$result = mysql_query("SELECT * FROM names")
or die(mysql_error());
// display data in table
echo "<table border='0' cellpadding='10' cellspacing='1' width='650'>";
echo "<tr> <th>ID</th> <th>Names</th><th>Delete</th></tr>";
// loop through results of database query, displaying them in the table
while($row = mysql_fetch_array( $result )) {
// echo out the contents of each row into a table
echo "<tr>";
echo '<td width="20">' . $row['id'] . '</td>';
echo '<td width="330">' . $row['Name'] . '</td>';
echo '<td width="150"><a class="btn-del" href="delete_name.php?id=' . $row['id'] . '">Delete</a></td>';
echo "</tr>";
}
// close table>
echo "</table>";
?>
<p><a class="btn-add" href="new_name.php">Add New name</a></p>
现在的问题是当我访问文件时出现此错误:
警告:session_start() [function.session-start]:无法发送会话 cookie - 标头已由 /home/xxxxxxxx/public_html/name/list/list_names.php:2 中的 /home/xxxxxxxx/public_html 发送(输出开始于 /home/xxxxxxxx/public_html /name/libraries/joomla/session/session.php 在第 532 行
警告:session_start() [function.session-start]:无法发送会话缓存限制器 - 标头已在 /home/xxxxxxxx/public_html 中发送(输出开始于 /home/xxxxxxxx/public_html/name/list/list_names.php:2) /name/libraries/joomla/session/session.php 在第 532 行访问被拒绝:需要登录。
我不是程序员!我正在边做边学,请帮助。问候,