解析错误:语法错误,意外'$ password'(T_VARIABLE)

时间:2014-01-27 12:14:53

标签: php syntax-error

我检查了一切。它仍然不起作用,当我在第6行中添加分号(;)时说

Parse error: syntax error, unexpected ';' in line 6

我该怎么办?这是我的代码:

<?php

if(isset($_POST['logintoadminpanel']))
(   

    include_once 'connection.php';

    $username = $_POST['username'];
    $password = $_POST['password'];


    if(empty($username) || empty($password))
    (
        echo "Please fill the required fields";
    )
)
?>

3 个答案:

答案 0 :(得分:4)

你正在使用parens for blocks。你需要使用大括号。

if (...)
{
   ...
}

答案 1 :(得分:1)

对if条件使用{}而不是()。

<?php

if(isset($_POST['logintoadminpanel']))
{

    include_once 'connection.php';

    $username = $_POST['username'];
    $password = $_POST['password'];


    if(empty($username) || empty($password))
    {
        echo "Please fill the required fields";
    }
}
?>

答案 2 :(得分:0)

Please check below tested code.. 

<?php

if(isset($_POST['logintoadminpanel']))
{

    include_once ('connection.php');

    $username = $_POST['username'];
    $password = $_POST['password'];


    if(empty($username) || empty($password))
    {
        echo "Please fill the required fields";
    }
}
?>