I'm having problems with my php script.
Im settings these variables:
$v1 = mysql_real_escape_string($_POST["v1"]);
$v2 = mysql_real_escape_string($_POST["v2"]);
$v3 = mysql_real_escape_string($_POST["v3"]);
$v4 = mysql_real_escape_string($_POST["v4"]);
I want these values to be updated to the row of my db where id = 1 every time (the row already exists and just need to be updated).
should I then insert or update the row? I've tried this without success:
$sql = "INSERT INTO table1 (v1, v2, v3, v4) WHERE id = 1";
$sql .= "VALUES ('$v1', '$v2', '$v3', '$v4')";
Use an UPDATE
rather than an INSERT
.
Try this:
UPDATE table1 set v1 = '$v1', v2 = '$v2', v3 = '$v3', v4 = '$v4' WHERE id = 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With