插入数据时,MySQL中未出现成功消息

时间:2019-05-24 11:39:02

标签: php mysql

插入数据时MySQL没有出现成功消息。我尝试了if(mysqli_query($ sql))和mysqli_affected_rows($ conn)。这是我的代码

<?php
if(isset($_POST['send']))
{
    $name = $_POST['cname'];
    $email = $_POST['cemail'];
    $mobile = $_POST['cmobile'];
    $message = $_POST['cmessage'];
    $sent = time();
    $conn = mysqli_connect("localhost","root","","charan");
    if($conn)
    {
        $sql = "INSERT INTO requests(cname,cemail,cmobile,cmessage,sent_at) VALUES('$name','$email','$mobile','$message',$sent)";
        $msent = mysqli_query($conn,$sql);
        if($msent)      
        {
            echo "request is sent";
        }
    }
}
?>

0 个答案:

没有答案