I've tried everything I know. I know it's not a database connection thing because I am running this in the same way I INSERT data and it's in the same function file.
function update($name, email, $id) {
$in = "UPDATE tablename
SET (name, email) VALUES('$name', '$email')
WHERE id = '$id'";
mysql_query($in);
}
You SQL should be like this
$in = "UPDATE tablename
SET name='$name', email='$email'
WHERE id='$id'";
And as noted by @Falcon, you missed a $
in your function arguments.
Your function
function update($name, email, $id) {
says email and inside is using $email. Change it to
function update($name, $email, $id) {
and check
try
update table_name
set
col1 = val1
col2 = val2
..........where id = $id;
The correct syntax is:
UPDATE tablename
SET name='$name',email='$email'
WHERE id = '$id'
Note: Make sure you sanitize the input.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.