Search code examples
phpparsingparse-errorphp-parse-error

Parse error: syntax error, unexpected '$Points' (T_VARIABLE)


I'm trying to make a form that updates a datebase but it gives me an error. Do you have any idea what it could be from? The error:

Parse error: syntax error, unexpected '$Points' (T_VARIABLE) in D:\2013.1\xampp\htdocs\ranklist_get.php on line 9

welcome.html

<body>
<form action="ranklist_get.php" method="get">
Skype: <input type="text" id="Skype"><br>
Points: <input type="number" id="Points"><br>
<input type="submit">
</form>
</body>
</html>

ranklist_get.php *The solved code by Abhik Chakraborty :)

<?php
$con=mysqli_connect("localhost","root","","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

mysqli_query($con,"UPDATE Persons SET Points='".$Points."' WHERE Skype='".$Skype."'");

mysqli_close($con);
?>

Solution

  • Change

    mysqli_query($con,"UPDATE Persons SET Points="$Points";
    WHERE Skype="$Skype""); 
    
    to 
    
    mysqli_query($con,"UPDATE Persons SET Points='".$Points."' WHERE Skype='".$Skype."'");