עבור לתוכן

Warning: Cannot modify header information

Featured Replies

פורסם

מה שיש לי זה דף עם נגן מדיה, אני מקבל את הכתובת של הסרטון בשורת הכתובות.

יש לי שני קישורים להחליף בין נגן פלאש לנגן QUICKTIME. ואני רוצה לשמור את הבחירה בעוגייה.

ההחלפה בין הנגנים עובדת, אבל הקטע עם העוגיות לא.

כשאני פותח את הדף הזה, אני מקבל שגיאת Cannot modify header information.

Warning: Cannot modify header information - headers already sent by (output started at /home/content/i/l/a/ilanfir/html/tests/qt.php:1) in /home/content/i/l/a/ilanfir/html/tests/qt.php on line 15

הקוד של הדף:

<?php
$expire = time()+60*60*24*30;
if(isset($_COOKIE["IFAplayer"]))
$player = $_COOKIE["IFAplayer"];
else
{
if(($_GET["p"] == "qt") || ($_GET["p"] == "fl"))
{
$player = $_GET["p"];
setcookie("IFAplayer", $player, $expire);
}
else
{
$player = "fl";
setcookie("IFAplayer", $player, $expire);
}
}
?>
<html dir="rtl">
<head>
<script type="text/javascript" src="includes/funcs.js"></script>
</head>
<body>
<center>
<?php
$movieURL = $_GET["movieURL"];
$poster = substr($movieURL, 0, -4);
$poster .= "_poster.jpg"; // SET THE POSTER IMAGE URL TO [moviename here]_poster.png


if($player == "qt")
{
?>
<!-- QUICKTIME PLAYER -->
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="[url]http://www.apple.com/qtactivex/qtplugin.cab"[/url] height="616" width="800">
<param name="src" value="[url]http://www.inforall.net/videos/<?=[/url] $movieURL; ?>">
<param name="autoplay" value="true">
<param name="type" value="video/quicktime" height="616" width="800">
<embed src="[url]http://www.inforall.net/videos/<?=[/url] $movieURL; ?>" height="616" width="800" autoplay="true" type="video/quicktime" pluginspage="[url]http://www.apple.com/quicktime/download/">[/url]
</object>
<!-- QUICKTIME PLAYER END -->
<?php
}
else
{
?>
<!-- FLASH PLAYER -->
<script type="text/javascript" src="/embed/swfobject.js"></script>

<div id="player">אראה שגיאה במהלך טעינת הנגן.<br />
אנא בדוק אם <a href="[url]http://get.adobe.com/flashplayer">Adobe[/url] Flash Player</a> מותקן אצלך.</div>

<script type="text/javascript">
var so = new SWFObject('/embed/player.swf','mpl','800','616','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');

so.addParam('flashvars','&file=/videos/<?= $movieURL ?>ℑ=/videos/previews/<?= $poster ?>');

so.write('player');
</script>
<!-- FLASH PLAYER END -->
<?php
}
?>

<br />
<div style="text-size: small;"><a href="<?= $_SERVER['PHP_SELF'] . '?movieURL=' . $movieURL ?>&p=fl">נגן Flash</a> | <a href="<?= $_SERVER['PHP_SELF'] . '?movieURL=' . $movieURL ?>&p=qt">נגן Quicktime</a></div>

</center>
</body>
</html>

מישהו רואה מה הבעיה?

תודה...

פורסם
  • מחבר

אני עדיין מקבל שגיאה.

אם אני משתמש בסוף ב- ob_end_clean, אז אין שגיאה, אבל הוא גם לא שומר את העוגיות...

פורסם

עדיף ob_end_flush (ולקרוא מה הפקודות עושות).

כמובן ה ob_start אמור להיות הפקודה הראשונה בעמוד.

פורסם
  • מחבר

שמתי את ה ob_start() בשורה הראשונה, וניסיתי לשים את ob_end_flush אחרי הקוד php.

גם קיבלתי את השגיאה.

ניסיתי גם לשים את ה ob_end_flush בסוף הדף, גם זה נתן לי את אותה השגיאה.

<?php
ob_start();
$expire = time()+60*60*24*30;
if(isset($_COOKIE["IFAplayer"]))
$player = $_COOKIE["IFAplayer"];
else
{
if(($_GET["p"] == "qt") || ($_GET["p"] == "fl"))
{
$player = $_GET["p"];
setcookie("IFAplayer", $player, $expire);
}
else
{
$player = "fl";
setcookie("IFAplayer", $player, $expire);
}
}
ob_end_flush(); // פעם ראשונה ניסיתי פה, לא עבד
?>
<html dir="rtl">
<head>
<script type="text/javascript" src="includes/funcs.js"></script>
</head>
<body>
<center>
<?php
$movieURL = $_GET["movieURL"];
$poster = substr($movieURL, 0, -4);
$poster .= "_poster.jpg"; // SET THE POSTER IMAGE URL TO [moviename here]_poster.png


if($player == "qt")
{
?>
<!-- QUICKTIME PLAYER -->
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="[url]http://www.apple.com/qtactivex/qtplugin.cab"[/url] height="616" width="800">
<param name="src" value="[url]http://www.inforall.net/videos/<?=[/url] $movieURL; ?>">
<param name="autoplay" value="true">
<param name="type" value="video/quicktime" height="616" width="800">
<embed src="[url]http://www.inforall.net/videos/<?=[/url] $movieURL; ?>" height="616" width="800" autoplay="true" type="video/quicktime" pluginspage="[url]http://www.apple.com/quicktime/download/">[/url]
</object>
<!-- QUICKTIME PLAYER END -->
<?php
}
else
{
?>
<!-- FLASH PLAYER -->
<script type="text/javascript" src="/embed/swfobject.js"></script>

<div id="player">אראה שגיאה במהלך טעינת הנגן.<br />
אנא בדוק אם <a href="[url]http://get.adobe.com/flashplayer">Adobe[/url] Flash Player</a> מותקן אצלך.</div>

<script type="text/javascript">
var so = new SWFObject('/embed/player.swf','mpl','800','616','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');

so.addParam('flashvars','&file=/videos/<?= $movieURL ?>ℑ=/videos/previews/<?= $poster ?>');

so.write('player');
</script>
<!-- FLASH PLAYER END -->
<?php
}
?>

<br />
<div style="text-size: small;"><a href="<?= $_SERVER['PHP_SELF'] . '?movieURL=' . $movieURL ?>&p=fl">נגן Flash</a> | <a href="<?= $_SERVER['PHP_SELF'] . '?movieURL=' . $movieURL ?>&p=qt">נגן Quicktime</a></div>

</center>
</body>
</html>
<?php
//ob_end_flush(); // גם ניסיתי פה, גם זה החזיר לי את השגיאה
?>

השינוי היחיד בהודעת שגיאה, זה שה on line 15 הפעם הפך ל-16

פורסם

הממ.. אולי אתה שומר את הקובץ כ UNICODE ? נסה לשמור אותו כ ANSI ולראות אם זה משפיע.

פורסם
  • מחבר

אכן זאת היתה הבעיה.

תודה רבה :xyxthumbs:

אני לא מאמין ששטות כזאת יכולה לעשות כל כך הרבה בעיות...

פורסם

אם בכל זאת אתה רוצה לשמור unicode שם, תדאג להשתמש בעורך נורמלי ולסמן unicode without bom.

פורסם
  • מחבר

אני משתמש ב notepad ++ והקובץ היה שמור כ utf-8.

מה אומר בעצם ה without bom הזה?

פורסם

יש לך אופציה בעורך הזה, לעשות convert to utf-8 without bom

מה זה ?

http://en.wikipedia.org/wiki/Byte-order_mark

העורך דוחף את זה להתחלה של הקובץ אם אתה לא עושה בלי זה (וזה בלתי נראה).

פורסם
  • מחבר

אוקיי...

תודה רבה :xyxthumbs:

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים