Skip to main content
100%

Check SQL in PHP

✓ Published0🌍 Public
LLayne Smith
Last edited Jun 18, 2015
Created on Jun 18, 2015

This example shows a PHP script that checks for duplicate IP addresses in a database table before inserting a new record. The code constructs a SQL query by concatenating the table name and IP variable directly into a `SELECT COUNT(*)` statement, then executes it with the `db->query()` method. If the query fails, it prints the database error information using `$db->errorInfo()`. The result is retrieved via `fetchColumn()`, returning the count that indicates whether the IP already exists. The visualization highlights the string interpolation in the SQL statement, demonstrating a classic SQL injection vulnerability.

AI-generated description

Similar vizzes