PHP中的小错误,我找不到。意外的T_VARIABLE

时间:2013-04-18 15:07:23

标签: php forms error-handling

我正在尝试使用当前语法解析表单,我很确定大部分内容都是正确的。我只是不断收到此错误:解析错误:语法错误,第13行/home/pftech/public_html/wp-content/themes/pureflo/formhandler.php中的意外T_VARIABLE。我真的迷失在这可能是什么以及为什么它导致整个表格失败。请非常感谢您对此事的任何帮助。刚刚失去了。谢谢!

<?php
/**
 * Template Name: Form Handler
 */
?>  
 <?php
    if(isset($_GET['zip'])){
        $sandiego = array('91911', '91914', '91915', '91932', '91942', '91945', '91950', '92014', '92025', '92027', '92029', '92037', '92064', '92065', '92067', '92071', '92075', '92101', '92102', '92103', '92104', '92105', '92106', '92107', '92108', '92109', '92110', '92111', '92113', '92114', '92115', '92116', '92117', '92118', '92119', '92120', '92121', '92122', '92123', '92124', '92126', '92127', '92128', '92129', '92130', '92131', '92132', '92134', '92135', '92139', '92140', '92145', '92147', '92154', '92173', '92562', '92563', '92590', '92591', '92592', '92596');
      if (in_array($_GET['zip'], $sandiego)){
          $urls = array();
            if($_GET["office"] == 1) { 
                $urls[] = "http://50.22.79.62/~pftech/office-delivery/"
                $urls[] = "http://50.22.79.62/~pftech/office-delivery/"
                $urls[] = "http://50.22.79.62/~pftech/office-delivery/"
            } else {
                $urls[] = "http://50.22.79.62/~pftech/water-delivery-service/"
                $urls[] = "http://50.22.79.62/~pftech/coffee-delivery/"
                $urls[] = "http://50.22.79.62/~pftech/water-filtration-systems/"
            }
            if($_GET['selection'] < 3 && $_GET['selection'] >= 0) {
                $URL = $urls[$_GET['selection']];
                header("Location: $URL?zip=$_GET[zip]");
            } else header("Location: http://50.22.79.62/~pftech/nationwide/"); 
        } else {
            header("Location: http://50.22.79.62/~pftech/nationwide/");
        }
    }
    exit;

2 个答案:

答案 0 :(得分:2)

每行后都没有;分隔符

答案 1 :(得分:1)

此代码有效

    <?php
/**
 * Template Name: Form Handler
 */
?>  
 <?php
    if(isset($_GET['zip'])){
        $sandiego = array('91911', '91914', '91915', '91932', '91942', '91945', '91950', '92014', '92025', '92027', '92029', '92037', '92064', '92065', '92067', '92071', '92075', '92101', '92102', '92103', '92104', '92105', '92106', '92107', '92108', '92109', '92110', '92111', '92113', '92114', '92115', '92116', '92117', '92118', '92119', '92120', '92121', '92122', '92123', '92124', '92126', '92127', '92128', '92129', '92130', '92131', '92132', '92134', '92135', '92139', '92140', '92145', '92147', '92154', '92173', '92562', '92563', '92590', '92591', '92592', '92596');
      if (in_array($_GET['zip'], $sandiego)){
          $urls = array();
            if($_GET["office"] == 1) { 
                $urls[] = "http://50.22.79.62/~pftech/office-delivery/";
                $urls[] = "http://50.22.79.62/~pftech/office-delivery/";
                $urls[] = "http://50.22.79.62/~pftech/office-delivery/";
            } else {
                $urls[] = "http://50.22.79.62/~pftech/water-delivery-service/";
                $urls[] = "http://50.22.79.62/~pftech/coffee-delivery/";
                $urls[] = "http://50.22.79.62/~pftech/water-filtration-systems/";
            }
            if($_GET['selection'] < 3 && $_GET['selection'] >= 0) {
                $URL = $urls[$_GET['selection']];
                header("Location: $URL?zip=$_GET[zip]");
            } else header("Location: http://50.22.79.62/~pftech/nationwide/"); 
        } else {
            header("Location: http://50.22.79.62/~pftech/nationwide/");
        }
    }
    exit;
?>

我添加了;这结束了一个php函数