douhao7677 2014-01-02 10:19
浏览 152
已采纳

PHP解析错误:语法错误,意外T_VARIABLE [关闭]

I get this error: PHP Parse error: syntax error, unexpected T_VARIABLE on line 47

The 47th line is:

$queryb = "UPDATE `situation` SET `status`='" . $stats . "', `time`='" . $time . "', `name`='" . $name . "', `notes`='" . $notes . "'";

I just don't get it. Maybe script error or syntax error?

<?php
    function lanjut($c) {
    $submitdata = "success";
    if ($c = "message") {
        $time = $_REQUEST['time'];
        $name = $_REQUEST['name'];
        $body = $_REQUEST['body'];
        $con = mysqli_connect("this,is,already,true");
        $querya = "INSERT INTO `message` (`name`, `time`, `body`) VALUES ('" . $name . "', '" . $time . "', '" . $body . "')";
        mysqli_query($con,$query);
        mysqli_close($con);
    } elseif ($c = "setting") {
        $time = $_REQUEST['time'];
        $name = $_REQUEST['name'];
        $notes = $_REQUEST['notes'];
        $con = mysqli_connect("this,is,already,true");
        $stats = $_REQUEST['status']
        $queryb = "UPDATE `situation` SET `status`='" . $stats . "', `time`='" . $time . "', `name`='" . $name . "', `notes`='" . $notes . "'";
        mysqli_query($con,$query);
        mysqli_close($con);
    };
};
?>
  • 写回答

4条回答 默认 最新

  • dplece1882 2014-01-02 10:32
    关注

    Code without any syntax error will be

    <?php
    function lanjut($c)
    {
        $submitdata = "success";
        if($c = "message") {
            $time = $_REQUEST['time'];
            $name = $_REQUEST['name'];
            $body = $_REQUEST['body'];
            $con = mysqli_connect("this,is,already,true");
            $querya = "INSERT INTO `message` (`name`, `time`, `body`) VALUES ('" . $name . "', '" . $time . "', '" . $body . "')";
            mysqli_query($con, $querya);
            mysqli_close($con);
        } elseif($c = "setting") {
            $time = $_REQUEST['time'];
            $name = $_REQUEST['name'];
            $notes = $_REQUEST['notes'];
            $con = mysqli_connect("this,is,already,true");
            $stats = $_REQUEST['status'];
            $queryb = "UPDATE `situation` SET `status`='" . $stats . "', `time`='" . $time . "', `name`='" . $name . "', `notes`='" . $notes . "'";
            mysqli_query($con, $queryb);
            mysqli_close($con);
        }
    }
    ?>
    

    A better way is to user prepared statements like

    $querya = $con->prepare("INSERT INTO `message` (`name`, `time`, `body`) VALUES (? , ?, ?");
    $querya->bind_param('sss', $name, $time, $body);        
    $querya->execute();
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?