У меня есть веб-сайт с проблемой пробелов. Я включаю несколько файлов до doctype
и это вызывает пустое пространство для вывода.
После поиска я нашел это решение:
Проблема с пробелами перед типом документа
Однако после удаления ?>
я все еще получаю проблему. Ниже приведен код:
<?php
include ("include/session.php");
include ("include/updatestage.php");
?>
<!DOCTYPE HTML>....
Вот session.php
:
<?php session_start();
// if a team name has been assigned to a session...
if ( isset($_SESSION ['teamName']))
{
//create "global variable $teamName that can be used across all pages as long as the function "session_start(); is present"
$teamName = $_SESSION ['teamName'];
}
else{
die ( "You are not logged in! Redirecting to login page...<meta http-equiv='REFRESH' content='2; url = index.php'>");
}
Вот updatestage.php
:
<?php
include("config.php");
//update stage
$inserted="n";
mysql_query ("UPDATE `team` SET `inserted`='$inserted' WHERE teamName = '$teamName' ");
$advance="n";
mysql_query ("UPDATE `game` SET `advance`='$advance' ");
Вот getstageinfo.php
:
<?php
include("include/config.php");
//Select the slogan from the current user
$currentStage = mysql_query("
SELECT `currentStage` FROM `team` WHERE `teamName` = '$teamName'
");
//assign the text located at the logo field (the path of the logo) to a variable $slogan
$row = mysql_fetch_assoc($currentStage);
$currentStage= $row['currentStage'];
?>
И, наконец, вот config.php
:
<?php
// connect to database
$con = mysql_connect("xxxxxxx","xxxxxxx","xxxxxxx");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
// select database
mysql_select_db ("xxxxxxx");
?>
/////////////////////////////////////////////// ///////////////////////////////////////////
Хорошо, я добавил обратно в?> И попробовал следующие предложения:
<!DOCTYPE HTML>
<?php
include("include/session.php");
include("include/updatestage.php");
?>
Или пытается:
<?php
echo "<!DOCTYPE HTML>\n";
include ("include/session.php");
include ("include/updatestage.php");
?>
Производит:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at public_html/period1.php:2) in public_html/include/session.php on line 1
Попытка:
<?php
include("include/session.php");
include("include/updatestage.php");
?><!DOCTYPE HTML>
Или:
<?php
ob_start();
echo "<!DOCTYPE HTML>\n";
include ("include/session.php");
include ("include/updatestage.php");
ob_end_flush();
?>
По-прежнему создает пустое пространство.