dpyu7978 2012-12-18 06:22
浏览 19
已采纳

修复php中的解析错误[关闭]

how can i correct this error i am getting when i try to load my page,

Parse error: syntax error, unexpected $end in C:\xampp\htdocs\mysite\index.php on line 46

the code on line 46 is this one below

?>

and my code is this one

<?php session_start();?>

<!DOCTYPE html>
<html lang="en">
<?php
if (isset ($_post['submit'])){
    $error_count = 0;
    $error_message = array();
//trim removes the spaces
  $validate = trim(strtolower($_post['validate']));
  if($validate != get_answer() ){ 
  $error_count++;
  $error_message['validate'] = "validation error";
   }  
 echo $error_count;
if( $error_count > 0){
?>
<form method="post">
<h1> <?php create_function()?></h1>
<label for="validation">Validate:</label>
<input type="text" name="validate" id="validate" />
<?php if(isset($error_message['validate'])):?>
<span style="color: red"><?php echo $error_message['validate']?></span>
<?php endif;?>
<span style="color: green">Reenter Answer to Question</span>
<br/>
<input type="submit" name="submit" value="email">
</form>
<?php
}
else{
?>
<form method="post">
<h1> <?php create_function()?></h1>
<label for="validation">Validate:</label>
<input type="text" name="validate" id="validate" />
<br/>
<input type="submit" name="submit" value="email">
</form>
<?php
}
?>

what exactly am i doing wrong? and how can i fix it?

  • 写回答

2条回答 默认 最新

  • dtkyayvldeaqhl7151 2012-12-18 06:25
    关注

    You are missing one closing parenthesis } I guess it should there before last php closing tag ?>

     <!DOCTYPE html > <html lang = "en" >
      <? php if (isset($_post['submit'])) {
        $error_count = 0;
        $error_message = a rray(); //trim removes the spaces $validate=t rim(strtolower($_post[
        'validate']));
        if ($validate != g et_answer()) {
            $error_count++;
            $error_message['validate'] = "validation error";
        }
        echo $error_count;
        if ($error_count > 0) { ?>
        <form method="post">
    
    <h1> <?php create_function() ?></h1>
    
            <label for="validation">Validate:</label>
            <input type="text" name="validate" id="validate" />
            <?php if (isset($error_message['validate'])) : ?>
    <span style="color: red"><?php echo $error_message['validate'] ?></span>
    
            <?php
        endif; ?>
    <span style="color: green">Reenter Answer to Question</span>
    
                <br/>
                <input type="submit" name="submit" value="email">
        </form>
        <?php } else { ?>
        <form method="post">
    
    <h1> <?php create_function() ?></h1>
    
            <label for="validation">Validate:</label>
            <input type="text" name="validate" id="validate" />
            <br/>
            <input type="submit" name="submit" value="email">
        </form>
        <?php }
    } //guess you are missing this 
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度