Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7791535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:55:00+00:00 2026-06-01T21:55:00+00:00

In my SQL Queries I am submitting data from forms filled out by the

  • 0

In my SQL Queries I am submitting data from forms filled out by the user, and as shown here it is not possible to parameterize my column names with PDO. This is important because the column names in the query are inserted dynamically based on the field names in the form.

I can rather easily validate the column names submitted in the $_POST array by simply pulling them out of the database and throwing out any that don’t match. Is this a good thing to do to avoid SQL injection or is simply a waste of system resources (as it effectively doubles the execution of any request that relies on the Database)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:55:02+00:00Added an answer on June 1, 2026 at 9:55 pm

    Is this a good thing to do to avoid SQL injection

    No.

    or is simply a waste of system resources

    No.

    It cannot be a waste as it’s just a simple select from the system table.

    But it is still can be a some sort of injection when a user isn’t allowed to some fields. Say, if there is an (imaginary) field “user_role” filled by site admin and a user will have a possibility to define it in the POST, they can alter their access privileges.

    So, hardcoding (whitelisting) allowed fields is the only reliable way.

    as it effectively doubles the execution of any request that relies on the Database

    Man. Databases intended to be queried. It’s the only their purpose. A database that cannot sustain a simple select query is a nonsense. Queries are different. An insert one is way more heavy than 10 selects. You have to distinguish queries by quality, not quantity.

    the column names in the query are inserted dynamically based on the field names in the form.

    Though for the insert/update queries it is quite true, for the SELECT ones it is a BIG SIGN of the bad design. I can stand variable field names in the WHERE/ORDER BY clauses but if you have to vem in the fieldset of table name clauses – your database design is wrong for sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have two sql queries. select EmployeeID,FName from [Mydatabase].[dbo].EMPLOYEE_TABLE where EmployeeID not in (select
Looking for websites/books SQL queries from simple to advance (queries optimization and performanance etc..
While working with some random sql queries on our databases, we may not want
I suppose SQL queries fetch raw data... Is there any good point to start
What's the safest way of generating SQL queries in C#, including cleansing user input
I realize that parameterized SQL queries is the optimal way to sanitize user input
How can I make SQL queries from within emacs scripts to MySql then print
I encountered SQL queries that looked like select hello from foo.bar I found that
For sql queries like.. select Quantity_Books/datepart(hour,Rent_Hour) from Rent_Book where (some conditions..) They will return
I have 3 different SQL queries from 3 different unrelated tables (all using LIMIT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.