'What is the use of Curly Braces in PHP mysql? [duplicate]
I have seen in many source codes where developers used curly braces on the user input variable for ex:-
query("SELECT * FROM users WHERE email = '{$email}' AND password = '{$password}'");
And I have seen that people created two files (for may be some reasons) one with this query: retrieve.php
query("SELECT * FROM users WHERE email = $email AND password = $password");
and other file with this query: retrieve_safely.php
(note the filename)
query("SELECT * FROM users WHERE email = '{$email}' AND password = '{$password}'");
Now this creates a doubt to me, what is this difference between these two? What is the exact use for the curly braces in the query? Are they use to prevent from SQL injection? If so, how it can be?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|