SQL值查询更新错误

时间:2022-04-19 20:42:54

Hello guys I have an error in this query and again I cant Figure out what is wrong? i cant find the error. I know this is a simple code but Can you guys please help me in solving this

大家好,我在这个查询中有错误,我再也找不到有什么问题?我找不到错误。我知道这是一个简单的代码,但你能帮助我解决这个问题

I got an error

我收到了一个错误

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 'where testid=4 and qnid=1' at line 1

您的SQL语法有错误;查看与您的MySQL服务器版本对应的手册,以便在第1行的'where testid = 4和qnid = 1'附近使用正确的语法

$query = "update question set question='" . htmlspecialchars($_REQUEST['question'],ENT_QUOTES) . "',optiona='" . htmlspecialchars($_REQUEST['optiona'],ENT_QUOTES) . "',optionb='" . htmlspecialchars($_REQUEST['optionb'],ENT_QUOTES) . "',optionc='" . htmlspecialchars($_REQUEST['optionc'],ENT_QUOTES) . "',optiond='" . htmlspecialchars($_REQUEST['optiond'],ENT_QUOTES) . "',correctanswer='" . htmlspecialchars($_REQUEST['correctans'],ENT_QUOTES) . "',marks='" . htmlspecialchars($_REQUEST['marks'],ENT_QUOTES) . "',audiopath=" . htmlspecialchars($_REQUEST['AudioPath'],ENT_QUOTES) . " where testid=" . $_SESSION['testqn'] . " and qnid=" . $_REQUEST['qnid'] . " ;";
    if (!@executeQuery($query))
        $_GLOBALS['message'] = mysql_error();
    else
        $_GLOBALS['message'] = "Question is updated Successfully.";
}

Thank for those who will answer

感谢那些愿意回答的人

2 个解决方案

#1


0  

This should be what you need. You are missing quotes. Looks like you also have an extra semi-colon there.

这应该是你需要的。你缺少报价。看起来你还有一个额外的分号。

audiopath='" . htmlspecialchars($_REQUEST['AudioPath'],ENT_QUOTES) . "' where testid='" . $_SESSION['testqn'] . "' and qnid='" . $_REQUEST['qnid'] . "'";

#2


0  

To make your app more secure I would use PDO extensions http://www.phptherightway.com/#pdo_extension

为了使您的应用更安全,我将使用PDO扩展http://www.phptherightway.com/#pdo_extension

#1


0  

This should be what you need. You are missing quotes. Looks like you also have an extra semi-colon there.

这应该是你需要的。你缺少报价。看起来你还有一个额外的分号。

audiopath='" . htmlspecialchars($_REQUEST['AudioPath'],ENT_QUOTES) . "' where testid='" . $_SESSION['testqn'] . "' and qnid='" . $_REQUEST['qnid'] . "'";

#2


0  

To make your app more secure I would use PDO extensions http://www.phptherightway.com/#pdo_extension

为了使您的应用更安全,我将使用PDO扩展http://www.phptherightway.com/#pdo_extension