Update database

Hi, i am trying to update som info in my database with php. I use mysql.

[php]//Create INSERT query
$qry = (“UPDATE kunder SET epost={$_POST[‘email’]}, fordon={$_POST[‘fordon’]}, hyresbelopp={$_POST[‘hyresbelopp’]}, name={$_POST[‘name’]}, ettavtal={$_POST[‘ettavtal’]}, tvaavtal={$_POST[‘tvaavtal’]}, treavtal={$_POST[‘treavtal’]}, fyraavtal={$_POST[‘fyraavtal’]}, femavtal={$_POST[‘femavtal]’}, sexavtal={$_POST[‘sexavtal’]}, sjuavtal={$_POST[‘sjuavtal’]}, attaavtal={$_POST[‘attaavtal’]}, nioavtal={$_POST[‘nioavtal’]} WHERE id={$_POST[‘id’]}”);
$result = @mysql_query($qry);[/php]

Currently I get syntax error, unexpected ‘}’, expecting ‘]’ on the $qry

I’ve tried to put every column inside [] as it says on dev.mysql. Example, [, name={$_POST[‘name’]}]

How can I make this to a functional update script?

try this, im pretty sure you dont need the curly brackets after SET and i removed the @ from your mysql_query
[php]//Create INSERT query

$qry = (“UPDATE kunder SET epost=$_POST[‘email’], fordon=$_POST[‘fordon’], hyresbelopp=$_POST[‘hyresbelopp’], name=$_POST[‘name’], ettavtal=$_POST[‘ettavtal’], tvaavtal=$_POST[‘tvaavtal’], treavtal=$_POST[‘treavtal’], fyraavtal=$_POST[‘fyraavtal’], femavtal=$_POST[‘femavtal]’, sexavtal=$_POST[‘sexavtal’], sjuavtal=$_POST[‘sjuavtal’], attaavtal=$_POST[‘attaavtal’], nioavtal=$_POST[‘nioavtal’] WHERE id=$_POST[‘id’]”);

$result = mysql_query($qry) or die(mysql_error());[/php]

The code is now functional. I forgot to put =’ ’

//Create INSERT query

$qry = (“UPDATE kunder SET epost=’{$_POST[‘email’]}’ WHERE id=’{$_POST[‘id’]”)’};

$result = mysql_query($qry) or die(mysql_error());

And the @ was deleted to, find out that it means to run the code though you get error message. It happends to be so that I like error messages :stuck_out_tongue:

Thank you for the help!

Sponsor our Newsletter | Privacy Policy | Terms of Service