Giter VIP home page Giter VIP logo

mysqli-connection-library's Introduction

mysqli-connection-library

Simple and easy procedural PHP script for connecting to a MySQL database.

mysqli-connection-library is based on the PHP MySQLi Extension for handling database connections. This system is based on the one implemented in BlogDraw for secure database connections!

How To Use

Example Usage

<?php
// If you define these, the library will use them by default.  
// Either block the file with these saved via .htaccess, or put it above your web root to ensure database security.
define(DBUSER, 't3stUser');
define(DBPASS, '1nSecureP3ssW0rd');
define(DBSERVER, '128.365.1.256');
define(DBNAME, 'fakeDatabase');

// Call the library.
require_once('mysqli-connection-library.php');

// Connect to the database.  If you've defined the values above, just call this:
$dBConnection = connect();

//Or you can define connection values manually:
$dBConnection = connect($server, $username, $password, $databaseName, $port, $socket);

$userInputString = "My name is: ');DROP TABLES ...";
// Clean SQL injection attempts from the string.
$saferUserInputString = cleanString($userInputString);

$userInputHtmlString = "<strong>My name is:</strong> ');DROP TABLES ...";
// Clean SQL injection attempts from the string, whilst preserving HTML tags.
$saferUserInputHtmlString = cleanHtmlString($userInputHtmlString);

// Put your query through to the database using mysqli_query().
$dBQuery = "SELECT [...]";// You can use a prepared statement here for better security.
$returnQuery = mysqli_query($dBConnection,$dBQuery);
// If you're expecting a result set, use mysqli_fetch_array().
while ($row = mysqli_fetch_array($returnQuery, MYSQLI_ASSOC))
  //Iterate through results in $row[].

// Disconnect from the database.
disconnect($dBConnection);
?>

API Documentation

View the complete API documentation here: jamesphillipsuk.github.io/mysqli-connection-library.

System Requirements

  • PHP 7.1 or later (Including PHP 8).
    • With mbstring and MySQLi extensions (these are usually included by default).
  • MySQL (or compatible) database server.

Bug-finding

I hope you don't have too many problems with this library, but if you do find any bugs, please report them as issues in the GitHub repo.

More From me

If you want to see more of what I do, you can visit: my blog. If you want to donate to my development efforts, you can send donations via PayPal.Me.

mysqli-connection-library's People

Contributors

jamesphillipsuk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.