我不确定在他们排队后我能读多少次关于或计算大括号,括号和分号的帖子。这已经让我困扰了好几个小时。任何见解都将不胜感激。
这个程序一天大部分时间都处于打开和关闭状态。当我发布它并且它有效时,我会看到需要注意的细节。有时候对它进行调整就会崩溃,就像这样。
文本内容无关紧要,因为在取出后问题仍然存在。 说它是第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');
?>
答案 0 :(得分:6)
不确定,但我认为问题在于:
else (
($bid_value < $value) ||
(empty($bid_value))
)
(condition)
关键字后面不能有else
。
答案 1 :(得分:3)
错误
else (
($bid_value < $value) ||
(empty($bid_value))
)
你不能在中使用条件用替换
答案 2 :(得分:2)
else (
($bid_value < $value) ||
(empty($bid_value))
)
{
以下是错误您无法在else
语句中使用条件
if-else
statemtent的基本结构是
if(condition){
//condition is true
}else{
//condition is false
}
如果您想使用更多条件而不是使用elseif
if(condition){
//condition is true
}elseif(condition){
//condition is false
}else{
}
您正在使用单个elseif
声明。
答案 3 :(得分:1)
看这里:
else (
($bid_value < $value) ||
(empty($bid_value))
)
{
现在让我们稍微缩小一点:
else (($bid_value < $value) || (empty($bid_value))) {
然后你非常明显地看到问题。在else
语句之后,您不仅仅有一个条件。在PHP中使用else语句的设计(参见PHP.net documentation for the else control structure)可以清除if
语句的所有可能情况。这使得它无法接受任何条件,因为其他条件不接受的任何条件都会进入else
语句。