Php语法,带有用户输入组件的数据库请求

I need some help with the php syntax for when user input is a variable in the request to the database.

The below manually enters values:

"UPDATE customer SET first_name= 'Me2' WHERE id = ' 13 ' ";

However i want the user to be able to enter values such as this:

"UPDATE customer SET first_name=".$edit_first_name.", WHERE id=".$edit_id."\"";

When i run the above it doesn't work as the first example script does. An i'm assuming it's a syntax problem, an there is no display on the page to indicate the issue location. Please help

You miss simple quotes '' around your $edit_first_name as it is a string.

Your query is wrong. Don't insert , before WHERE & put single quotes around string value.

"UPDATE customer SET first_name='".$edit_first_name."' WHERE id=".$edit_id;

This is the final query:

$update="UPDATE customer SET first_name=".$edit_first_name." WHERE id=".$edit_id;

try this statement, maybe it could solve your problem:

"UPDATE customer SET first_name ='$edit_first_name' WHERE id='$edit_id'";