Trying to Update Fields in MySQL with PHP code - help


My code is not working…it won’t update mySQL table and when I put in an integer instead of a variable for the VALUES it only does it once and then never does it again. Please look at my code and let mek now if u can help. I am inserting fields in to my database through changes the user makes through a form.

if (isset($edit) && $edit==“editfilm”) {
echo’You have edited film: '.$title;


Click here to return to the main page’;
$change_result=“update short_films set”.
“where id =’”.$_GET[‘id’]."’";
$change_result = mysql_query($change,$connect);



Hi Chooch,

Welcome to the forum. What error messages are you receiving if any? I think you might need to show us more code, but here are a couple of observations with what you have displayed.

Firstly, your $edit variable should be accessed using a superglobal array. I assume this is a POST variable, so change:

if (isset($edit) && $edit=="editfilm")


if ((isset($_POST['edit'])) && ($_POST['edit']=="editfilm"))

Next, change your query to the following:

$change_result="UPDATE short_films SET arrange='".$_GET['arrange']."' WHERE id ='".$_GET['id']."'";

The capital letters are a personal preference and are not necessary. I have just removed some of the quotes and dots.