为什么在这里没有正确比较

时间:2017-08-31 14:12:20

标签: php date

似乎我在做一些非常基本的错误。我希望进行比较的简单程序失败。

几个问题: 1.请求你帮我找出这里的错误,比较它在第一个条件下继续进行比较并打印空白区域 2.我无法获取datetimepicker1的值

请帮助!!

<?php

    $name = trim(stripslashes($_REQUEST['name']));
    $email = trim(stripslashes($_REQUEST['email']));
    $phone = trim(stripslashes($_REQUEST['phone']));
    $city = trim(stripslashes($_REQUEST['city']));
    $datetimepicker1 = trim(stripslashes($_REQUEST['datetimepicker1']));
    $placeofbirth = trim(stripslashes($_REQUEST['placeofbirth']));
    $message = trim(stripslashes($_REQUEST['message']));

    $response = '';
    $result = -100;


    //conection:
    $link = mysqli_connect("localhost","admin","qw@123","graph") or die("Error " . mysqli_error($link));

    //consultation:
    $query = "INSERT INTO user_msg 
                    (user_msg_name, user_msg_email, user_msg_phone, 
                    user_msg_city, user_msg_dob, user_msg_birthtime,     
                    user_msg_birthplace, user_msg_messages, 
                    user_msg_section) 
                values ('$name','$email','$phone',
                        '$city', '$datetimepicker1', '$datetimepicker1',
                        '$placeofbirth', '$message', 'contactus')" ;

    //execute the query.
    $result = $link->query($query) or die("Error in the consult.." . mysqli_error($link));

    //display information:
    if($result == -100)
    {
        $response = ' ';
    }
    elseif( $result > 0 )
    {
       $response = "Thank you $fname $lname for contacting us!<br/>";
    }
    else
    {
         $response = "Sorry, there has been an error, please try later.<br/>";
    }

    echo ' response='.$response;
?>

1 个答案:

答案 0 :(得分:0)

感谢@RiggsFolly的指导。

是的,它给出了真假作为回报价值。我指的是错误的方式。 并且没有要求定义$ result = -100。实际上我试图在我的一个表格中使用它并在那里做了一些基本的错误。

以下工作非常顺利。

if ($result === TRUE) {
    $response = "Thanks for connected with us. We'll get in touch with you soon!!";
} else {
    $response = "Error: " . $sql . "<br>" . $conn->error;
}

无论如何,谢谢你的帮助。