What is wrong with this query: "SELECT * FROM table WHERE id = $_POST[ 'id' ]"?
home / developersection / forums / what is wrong with this query: "select * from table where id = $_post[ 'id' ]"?
What is wrong with this query: "SELECT * FROM table WHERE id = $_POST[ 'id' ]"?
Kirti Sharma
03-Nov-2022The use of table keyword it displays error when we execute the query SELECT * FROM table WHERE id = $_POST[ 'id' ]'?
Siddhi Malviya
28-Oct-2022Never use user input directly in queries.
This works:
$_POST['id'] = 27;
$sql = 'SELECT * FROM table WHERE id = $_POST[ 'id' ]'; echo $sql;
l = 'SELECT * FROM table WHERE id = $_POST[ 'id' ]';
echo $sql;