0

I'm using PDO to prepare querys, but when I put # or -- (SQL commentaries) it still working (I know PDO won't disable it) how to make it stop? this comments break my whole code. (I want allow to use it but stop breaking)
Eg:
SELECT * FROM something WHERE var=:var AND value=:value
I just put # and this happens
SELECT * FROM something WHERE var=:var# AND value=:value only will check for var/:var
(Assume :var was user input using #)

1
  • 1
    Why not just name the parameter :varnum instead of using characters that will break the query? Commented Jul 21, 2012 at 21:28

1 Answer 1

2

Enclose your variables with single quotes:

SELECT * FROM something WHERE var=':var#' AND value=':value' 
Sign up to request clarification or add additional context in comments.

1 Comment

I didn't know single quotes disable comments, Thanks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.