Help with update into mysql with php

Hi All,

I’m trying to update a mysql row with php via a form but not having any luck. I’m a bit rusty so can’t figure out what I am doing incorrectly.
I’m letting users provide tags to some images within a record but I keep getting my output error.

if (isset($_GET['addtag']))
	$id = mysqli_real_escape_string($link, $_POST['id']);
	$tag = mysqli_real_escape_string($link, $_POST['tag']);
	$sql = "UPDATE table_name SET column_name='$tag', 
			WHERE id='$id'";
	if (!mysqli_query($link, $sql))

            $output = 'Error adding submitted tag.';

            include 'output.html.php';


<form action="?addtag" method="post" enctype="multipart/form-data">

Add Tag:<input type="text" id="tag" name="tag" size="20">

<input type="hidden" name="id" value="<?php echo($id); ?>" />
<input type="submit" value="Add" />



Are you using the correct column name?

Try echoing out the MySQL error to see what’s going wrong. Should be something like:

echo mysqli_error($link);

Also, you’ll need to remove the comma after ‘$tag’:

$sql = "UPDATE table_name SET column_name='$tag' WHERE id='$id'";