What is wrong with my code to update sql database the table is Informatie and i need to update the field Text.
$info = nl2br($_POST["info"]);
echo $info."<br>";
$infoid = $_POST["infoid"];
echo $infoid;
echo "<br>Info ID : $infoid";
$sql = "UPDATE Informatie set Text = $text WHERE InfoId = $infoid";
$query = mysql_query("$sql");
the echo $info and $infoid are correct.
i tryd
$sql = "UPDATE Informatie set Text = $text WHERE InfoId = '$infoid'";
also but it didnt work to
string values must be quoted.
if
InfoIDis also a string, then you also need to wrap it with single quotes.As a sidenote, the query is vulnerable with
SQL Injectionif the value(s) of the variables came from the outside. Please take a look at the article below to learn how to prevent from it. By usingPreparedStatementsyou can get rid of using single quotes around values.