Skip to content

Examples and best practices for establishing secure and efficient MySQLi connections in PHP.

Notifications You must be signed in to change notification settings

antonio-phpfullstack/mysqli-connection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP - MySQLi Connections

Purpose of This Repository

A brief story: In one of my early professional projects (a little over a decade ago), I had to migrate a PHP application to a newer version of MySQL. During the process, I realized the importance of using updated and secure extensions for database communication. That’s when I delved into using MySQLi, understanding its advantages and best practices. This repository aims to share that knowledge by providing practical examples of how to establish efficient and secure connections to MySQL databases using the MySQLi extension in PHP.

Project Structure

  • 01-connecting-to-the-database.php: Demonstrates how to establish a basic connection to the database using MySQLi.
  • 02-executing-commands-in-the-database.php: Provides examples of executing SQL commands in the database.
  • 03-listing-database-data.php: Shows how to retrieve and display data stored in the database.
  • 04-sql-injection.php: Highlights the risks of SQL Injection and how to prevent them.
  • 05-prepared-statement.php: Introduces the use of prepared statements to enhance query security.
  • 06-connection.php to 10-connection.php: Contains more advanced examples of CRUD operations (Create, Read, Update, Delete) using MySQLi.

How to Use This Project

  1. Clone the repository:

    git clone https://github.com/antonio-phpfullstack/mysqli-connection.git
    
  2. Environment Setup:

This project is based on the following repository:

If you do not have PHP installed on your host or wish to replicate the developer's environment, clone the repository above and place the PHP - MySQLi Connections repository inside the www/public directory.

  1. Running the Examples:

Each PHP file in the repository contains independent examples. It is recommended to run them individually to understand how each operation works.

Final Considerations

This repository aims to provide a solid foundation for developers who want to improve their skills in PHP and MySQLi. Remember, consistent practice and continuous learning are essential for professional growth. Good luck!

Releases

No releases published

Packages

No packages published

Languages