将更新的内容发布到数据库[关闭]

I am trying to change a row called "Name" in my database when a user submits the real_name part in my form.

//connect db
if(!empty($_POST['real_name'])){
mysql_query('UPDATE users SET Name = '.$_POST['real_name'].' WHERE id = '.$_SESSION['userid'].'');  
}

The if-statement is triggered correctly (I checked with echo and exit)

This is the form:

<form accept-charset="UTF-8" action="" method="post">
<input id="real_name" name="real_name" size="40" type="text" value="<?php echo $name; ?>" />

I also set the id part manually, so that should not be the issue either. Can anybody see a mistake? Thanks!

Name needs to be a string, so you should add double quotes around it, now you are just closing the text with single quotes. So it should be like this:

if(!empty($_POST['real_name'])){
mysql_query('UPDATE users SET Name = "'.$_POST['real_name'].'" WHERE id = '.$_SESSION['userid'].'');  
}