Urgent.News

What's breaking now, across hundreds of outlets.

Tech

PHP PDO and SQLite: SQL Injection, Shown Then Fixed

Series: PHP lecture 4/6 (intermediate). For developers who can write PHP classes and now need a database. By the end you can open a database with PDO, query it with prepared statements, show a teammate a working SQL injection on their own code, and fix it. This post is for developers who write or review PHP code that talks to a database, especially code that builds SQL with the . operator. We use…

PHP PDO and SQLite: Illustrating SQL Injection Then Mitigation

In this PHP tutorial, developers learn how to interact with a SQLite database using PDO, while also learning how to properly secure SQL queries against injection attacks.

First, the script creates two tables: 'users' and 'posts'. The developers then insert sample data into these tables using prepared statements with the PDO::ATTR_ERRMODE exception handling set to PDO::ERRMODE_EXCEPTION.

Next, the tutorial demonstrates a SQL injection vulnerability by showing how an attacker could manipulate the query to bypass authentication. The malicious input "' OR '1'='1" is used to force the query to always return true, allowing unauthorized access to all user records.

To fix the issue, the script demonstrates the proper use of prepared statements with parameterized queries. By using placeholders (?) instead of concatenating user input directly into the SQL query, the script ensures that the data is treated as literal values rather than executable code. This effectively neutralizes the SQL injection risk.

Finally, the tutorial emphasizes the importance of using the PDO::ATTR_ERRMODE exception handling option to catch and handle database errors explicitly. This helps prevent silent failures and makes debugging easier, as errors are surfaced as exceptions rather than being swallowed as default behavior.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Is AER-1 an official IETF standard?

The short answer No, not in the formal sense, and the precise answer matters more than a yes would. AER-1 is an IETF Internet-Draft: draft-zambo-aer1-26, authored by B.

  • AER-1 is not an official IETF standard, but an Internet-Draft
  • Internet-Draft authored by B. Zambo, dated 22 October 2026
  • Completed cross-framework interoperability check shows agreement between implementations

Found a Cracked Copy of Your App? A Practical Response Plan for Indie Devs

Originally published on the PermitCore blog . You found your paid desktop app on a warez site. Someone posted a keygen. A GitHub repository contains a modified build with your payment screen removed.

  • Determine type of infringement: cracked binary, keygen, re-upload, clone, or impersonation.
  • Escalate issue to lawyer if platform rejects notice or fails to respond.

What is an agent execution receipt standard?

The short answer An agent execution receipt standard is a published specification that defines, for a record of one AI agent tool call, four things exactly: what the record contains, how the commitment over its contents is computed, how an independent checker verifies it and what outcomes that checker is allowed to report, and a…

  • Agent execution receipt standard defines essential details of AI agent tool calls
  • AER-1 is a published IETF Internet-Draft exemplifying the standard
  • Receipt record includes execution details, commitment, verifier outcomes, and conformance corpus

More from Sunday 22 November →