---
title: "What is wrong with this query: \"SELECT * FROM table WHERE id = $_POST[ 'id' ]\"?"  
description: "What is wrong with this query: \"SELECT * FROM table WHERE id = $_POST[ 'id' ]\"?"  
author: "Erick Wilsom"  
published: 2022-10-27  
updated: 2022-10-27  
canonical: https://www.mindstick.com/forum/157175/what-is-wrong-with-this-query-select-from-table-where-id-_post-id  
category: "sql server reporting services"  
tags: ["sql server"]  
reading_time: 1 minute  

---

# What is wrong with this query: "SELECT * FROM table WHERE id = $_POST[ 'id' ]"?

What is [wrong](https://answers.mindstick.com/qa/48468/who-wrote-the-the-wrong-enemy-america-in-afghanistan-2001-2014-and-when) with this [query](https://www.mindstick.com/blog/202/sub-query-in-sqlserver): "[SELECT](https://www.mindstick.com/forum/160534/orderby-then-select-vs-select-then-orderby-performance) * FROM [table](https://www.mindstick.com/articles/43918/how-to-design-table-using-bootstrap) WHERE id = $_POST[ 'id' ]"?

## Replies

### Reply by Kirti Sharma

The use of table keyword it displays error when we execute the query SELECT * FROM table WHERE id = $_POST[ 'id' ]'?

### Reply by Siddhi Malviya

Never 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;

\


---

Original Source: https://www.mindstick.com/forum/157175/what-is-wrong-with-this-query-select-from-table-where-id-_post-id

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
