2014-04-08 65 views
-8

早上好,這是我第一次,我要求你幫忙。是的,我使用了搜索按鈕。我有這個問題:解析錯誤:語法錯誤,80行上的quest2.php中的意外T_ELSE。還有一個else語句。對不起,如果事實證明我是盲人。這裏的quest2.php代碼PHP - 意外的T_ELSE

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> 
<script type="text/javascript" src="http://jquery-countdown.googlecode.com/svn/trunk/js/jquery.countdown.js"></script> 
<style type="text/css"> 
     br { clear: both; } 
     .cntSeparator { 
     font-size: 54px; 
     margin: 10px 7px; 
     color: #000; 
     } 
     .desc { margin: 7px 3px; } 
     .desc div { 
     float: left; 
     font-family: Arial; 
     width: 70px; 
     margin-right: 65px; 
     font-size: 13px; 
     font-weight: bold; 
     color: #000; 
     } 
    </style> 

<?php 
require 'core.inc.php'; 
require 'connection.inc.php'; 
if(loggedin()) 
{ 
$rightvar=$_SESSION['user_id']; 
$result = mysql_query("SELECT * FROM users WHERE id = $rightvar") or die(mysql_error()); 
       $data = mysql_fetch_array($result); 
    $username=$data['username']; 
    $coins=$data['coins']; 
    $userid=$data['id']; 
$banned=$data['banned']; 
    $queststart = date('Y-m-d H:i:s', strtotime("+0 minutes")); 
$coinsget = rand(10, 100); 
$questactive=$data['questActive']; 
$questtime=$data['questTime']; 
$date = new DateTime('now'); 
$remaintime = date('i:s', strtotime($questtime) - strtotime($queststart)); 
$zamereni=$data['Zamereni']; 
$edit = $data['editActive']; 
$actualviews=$data['totalViews']; 
$viewsgetfromdb=$data['viewsGet']; 
$subsfromdb=$data['questReward']; 
$actualsubs=$data['coins']; 
$finalsubs = $subsfromdb + $actualsubs; 
$finalview = $actualviews + $viewsgetfromdb; 
echo '<script type="text/javascript">'; 
echo " $('#counter').countdown({"; 
echo " image: 'http://jquery-countdown.googlecode.com/svn/trunk/img/digits.png',"; 
echo " startTime: '" . $remaintime . "', "; 
echo " timerEnd: function(){ window.open('here I have the relevant path to quest2.php'," . '"_self"' . "); }, "; 
echo " format: 'mm:ss'"; 
echo " });"; 
echo "});"; 
echo "</script>"; 
if($questactive == 0) 
{ 
echo '<meta http-equiv="refresh" content="0;url=quest.php">Loading...'; 
} 
else 
{ 
echo 'Video bude/bylo natoceno: ' . $questtime . '<br>'; 
} 
if(strtotime($queststart) > strtotime($questtime)) 
{ 
echo '<title>' . 'Dokonceno' . ' - Nataceni videa - MyTube Simulator</title>Uz mas hotovo ' . '<br>'; 
if($edit == 1) 
{ 
echo '<meta http-equiv="refresh" content="0;url=edit2.php">Loading...'; 
} 
if($zamereni == 1) 
{ 
echo 'Prejes si sve video vyeditovat? <a href="chcieditovattodlenctomojevideo.php">Ano</a> nebo <a href="nechciniceditovatjsemliny.php">Ne</a>'; 
} 
    else 
    { 
    echo '<a href="upload.php">Mate hotovo - nahrat</a>'; 
    } 
    else //this is the else where the error happens 
    { 
    echo 'Hotovo nemas<br>'; 
    echo '<title>Nataceni videa - MyTube Simulator</title>Zbyva <div id="counter_2"></div><div class="desc"><div>Minut</div><div>Sekund</div></div>'; 
    } 
    else 
    { 
    echo '<a href="register">Register</a> or <a href="login.php">login</a>'; 
    } 
    ?> 

所以,你能幫我嗎?這裏就是錯誤發生

if($questactive == 0) 
{ 
echo '<meta http-equiv="refresh" content="0;url=quest.php">Loading...'; 
} 
else 
{ 
echo 'Video bude/bylo natoceno: ' . $questtime . '<br>'; 
} 
if(strtotime($queststart) > strtotime($questtime)) 
{ 
echo '<title>' . 'Dokonceno' . ' - Nataceni videa - MyTube Simulator</title>Uz mas hotovo ' . '<br>'; 
if($edit == 1) 
{ 
echo '<meta http-equiv="refresh" content="0;url=edit2.php">Loading...'; 
} 
if($zamereni == 1) 
{ 
echo 'Prejes si sve video vyeditovat? <a href="chcieditovattodlenctomojevideo.php">Ano</a> nebo <a href="nechciniceditovatjsemliny.php">Ne</a>'; 
} 
else 
{ 
echo '<a href="upload.php">Mate hotovo - nahrat</a>'; 
} 
else //this is the else where the error happens 
{ 
echo 'Hotovo nemas<br>'; 
echo '<title>Nataceni videa - MyTube Simulator</title>Zbyva <div id="counter_2"></div><div class="desc"><div>Minut</div><div>Sekund</div></div>'; 
} 
else 
{ 
echo '<a href="register">Register</a> or <a href="login.php">login</a>'; 
} 

我也必須注意到,代碼是正常工作之前,我tryed實現的jQuery 我居然錯過了一個支架有一部分......兩個支架,代碼現在工作

+1

您不能有多個'else'語句。擺脫他們,把他們全部在同一個塊。 –

+0

代碼工作正常,直到我嘗試實現jQuery倒計時 – Misabr

回答

2

您不能有多個else語句,請改用elseif

請參閱0123.net上的PHP.net文檔。

if($zamereni == 1) 
{ 
echo 'Prejes si sve video vyeditovat? <a href="chcieditovattodlenctomojevideo.php">Ano</a> nebo <a href="nechciniceditovatjsemliny.php">Ne</a>'; 
} 
else 
{ 
echo '<a href="upload.php">Mate hotovo - nahrat</a>'; 
} 
else //this is the else where the error happens 
{ 
echo 'Hotovo nemas<br>'; 
echo '<title>Nataceni videa - MyTube Simulator</title>Zbyva <div id="counter_2"></div><div class="desc"><div>Minut</div><div>Sekund</div></div>'; 
} 
else 
{ 
echo '<a href="register">Register</a> or <a href="login.php">login</a>'; 
} 

這就是問題所在。如果/ else語句是布爾值。如果表達式爲true,則執行if語句,如果表達式爲false,則執行else語句。沒有其他的可能性。