dongxiao0449 2010-12-10 09:53
浏览 44

mysql查询错误:有什么问题?

if($_GET['action'] == "add"){
        if($_SERVER['REQUEST_METHOD'] == "POST"){
            if(empty($_POST['bugtitle']) || empty($_POST['bugdetails'])){
                echo 'One of the fields was empty! Go back and try again.<br/>';
            }
            else
            {
                $query = "INSERT INTO bra
                          (
                            bugtitle,
                            bugdetails,
                            status,
                            ip,
                          )
                          VALUES
                          (
                            '". mysql_real_escape_string($_POST['bugtitle']) ."',
                            '". mysql_real_escape_string($_POST['bugdetails']) ."',
                            '0',
                            '". $_SERVER['REMOTE_ADDR'] ."'
                          )";
                $mysqlquery = mysql_query($query);

                if($mysqlquery){
                    echo 'Bug reported.<br/>';
                }
                else
                {
                    echo 'Mysql query failed! Please contact the webmaster!<br/>'.mysql_error().'<br/>'.$query;
                }
            }
        }
        else
        {
            ?>
            <form action="bra.php?action=add" method="post">
                Bug title: <input type="text" name="bugtitle"/><br/>
                Details:<br/>
                <textarea cols="50" rows="5" name="bugdetails"></textarea><br/>
                By pressing &#39;submit&#39; you understand that you will not spam and your ip adress will be logged.<br/>
                <input type="submit" value="submit"/>
            </form>
            <?php
        }
    }

And this is what it returned:

Mysql query failed! Please contact the webmaster! You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') VALUES ( 'There is a bug', 'And its call' at line 7 INSERT INTO bra ( bugtitle, bugdetails, status, ip, ) VALUES ( 'There is a bug', 'And its called maja', '0', '127.0.0.1' )

What is wrong with this query?!?

  • 写回答

3条回答 默认 最新

  • dougang6178 2010-12-10 09:54
    关注

    Remove the comma after ip.

    INSERT INTO bra
    (
        bugtitle,
        bugdetails,
        status,
        ip
    )
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入
  • ¥20 XP系统在重新启动后进不去桌面,一直黑屏。
  • ¥15 opencv图像处理,需要四个处理结果图
  • ¥15 无线移动边缘计算系统中的系统模型