为什么SQL代码没有运行?

I'm making a website which asks input from user using this html code:

<form>
     <input type="text" name="question1input1" />
</form>

But when I ran it on the second page using this php to upload into database:

$que1in1 = $_POST['question1input1'];

if ($que1in1 == "x-coordinate") {

    $answer = '<text style=\'color: yellowgreen;\'>x-coordinate</text>';

    $score = 1;

    $snumber = $_SESSION['DcYnuJmQKJkkBPEY'];

    $sql2 = "UPDATE `chapter 9 pre-test` SET `score1` = '$score' WHERE `chapter 9 pre-test`.`snumber`='$snumber';";

    $sql3 = "UPDATE `chapter 9 pre-test` SET `1` = '".$answer."' WHERE `chapter 9 pre-test`.`snumber`='$snumber';";

    if ($con->query($sql2) == TRUE) {}

    else {echo "something happened... ".$score;}

    if ($con->query($sql3) == TRUE) {}

    else {echo "something happened... ".$answer;}

}

$sql2 returning as success, but $sql3 returning as an error.

try changing your html code in $answer to use double quote since you are using single quote as a string delimiter in your update query

$answer = '<text style="color: yellowgreen;">x-coordinate</text>';

and if this is the cause of this problem, I suggest you use PDO and prepared statements instead. this will not happen if you are using prepared statements