June 2010
Intermediate to advanced
328 pages
7h 51m
English
SQL is intended to be used in concert with application code. When you build SQL queries as strings and combine application variables into the string, this is commonly called dynamic SQL.[25]
| SQL-Injection/obj/dynamic-sql.php | |
| | <?php |
| | $sql = "SELECT * FROM Bugs WHERE bug_id = $bug_id"; |
| | $stmt = $pdo->query($sql); |
This simple example shows interpolating a PHP variable into a string. We intend that $bug_id is an integer so that by the time the database receives the query, the value of $bug_id is part of the query.
Dynamic SQL queries are a natural way to get the most out of a database. When you use application data to specify how you want to query a database, you’re using SQL as a two-way language. Your ...
Read now
Unlock full access