-4

我不确定在大括号、方括号和分号排成一行后,我能读多少次或数一数。这已经折磨了我好几个小时。任何见解将不胜感激。

该程序大部分时间都在工作。当我发布它并且它起作用时,我会看到需要注意的细节。有时对其进行调整会使它崩溃,就像这样。

文本内容无关紧要,因为取出后问题仍然存在。说是第98行。

代码是否正确缩进?我试过了。

ini_set ('display_errors', 1);
error_reporting (E_ALL | E_STRICT);

require ('head_metas.htm');
require ('head_menus.htm');

//bid_handler.php

// get items
$title = trim($_POST['title']);
$img = trim($_POST['img']);
$medium = trim($_POST['medium']);
$size = trim($_POST['size']);
$date = trim($_POST['date']);
$value = trim($_POST['value']);

// visitor info
$visitorF = trim($_POST['visitorF']);
$visitorL = trim($_POST['visitorL']);
$phone = trim($_POST['phone']);
$email1 = trim($_POST['email1']);
$email2 = trim($_POST['email2']);
$validation1 = filter_var($email1, FILTER_VALIDATE_EMAIL);
$validation2 = filter_var($email2, FILTER_VALIDATE_EMAIL);

$bid_value = trim($_POST['bid_value']);

// confirmation mails
$headers = '...';
$to = 'my@email.com, $email1';
$subject = '...';
$message = $visitorF . $visitorL . ' has offered ' . $bid_value . ' for ' . $title . '.\n\nContact information:\nPnone: ' . $phone . '\nemail address: ' . $email1;

$okay = TRUE;
// welcome + image
if ($okay == TRUE)
{
    print "
        <p>
         Luring text and a captivating image
             <br />
             All \" quotes \" are meticulously struck
        </p>
          ";
    $okay = TRUE;
}



// inaccessible entries
if ( 
    (empty($visitorF)) || 
    (empty($visitorL)) || 
    (empty($email1)) || 
    (empty($email2)) || 
    ($email1 != $email2) ||
    ($validation1 == NULL) || 
    ($validation2 == NULL) 
    ) 
{
    print " 
        There were errors.
        ";
    $okay = FALSE;
}

    // everything looks great
    elseif ( 
        ($okay == TRUE) &&
        (is_numeric($bid_value)) && 
        ($bid_value >= $value) &&
        (isset($visitorF)) && 
        (isset($visitorL)) && 
        (isset($email1)) && 
        (isset($email2)) && 
        ($email1 == $email2) &&
        ($validation1 == TRUE) &&
        ($validation2 == TRUE) 
        ) 
    {
        print "
            <p>
              Thank you, your information is as follows:
              <br />
              Info... prints the variables in a stylish fashion
             </p> ";
             $okay = FALSE;
    }

        else ( 
            ($bid_value < $value) || 
            (empty($bid_value)) 
            )
        {
            print "
                <p>
                 However, your bid has not met the minimum reserve for this piece.
                <br />
                 Please enter a numeric value and try again.
                </p>
                 ";
            $okay = FALSE;
        }


require ('footer.html');
?>
4

4 回答 4

6

不确定,但我认为问题出在:

 else ( 
        ($bid_value < $value) || 
        (empty($bid_value)) 
        )

关键字(condition)后面不能有。else

于 2012-09-30T06:03:56.580 回答
3

错误输入

    else ( 
        ($bid_value < $value) || 
        (empty($bid_value)) 
        )

您不能在else中使用条件将其替换为else if删除条件

于 2012-09-30T06:15:43.137 回答
2
  else ( 
        ($bid_value < $value) || 
        (empty($bid_value)) 
        )
    {

这是错误您不能在语句中使用条件else语句的基本结构if-else

if(condition){
     //condition is true
}else{
     //condition is false
}

如果你想使用比使用更多的条件elseif

if(condition){
//condition is true
}elseif(condition){
//condition is false
}else{
}

您正在使用单个elseif语句。

于 2012-09-30T06:30:17.093 回答
1

看这里:

    else ( 
        ($bid_value < $value) || 
        (empty($bid_value)) 
        )
    {

现在让我们把它缩小一点:

else (($bid_value < $value) || (empty($bid_value))) {

然后你就很明显地看到了问题。您不只是在else语句之​​后有一个条件。PHP 中 else 语句的设计(有关 else 控制结构,请参见 PHP.net 文档)使其清除了if语句的所有可能情况。这使得它不能接受任何条件,因为其他条件不接受的任何东西都会进入else语句。

于 2012-09-30T06:08:16.827 回答