Documentation: mysqli-connection-library.

mysqli-connection-library.php

MySQLi Connection Library

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

Tags
copyright

(C) 2020 TuxSoft Limited, 2022 Jesse Phillips. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

author

Jesse Phillips james@jamesphillipsuk.com

version
0.0.1
since
0.0.1-rc1

Table of Contents

connect()  : mysqli
Connects to a database.
disconnect()  : void
Closes an open database connection.
cleanString()  : string
Creates an "escape string" to help prevent SQL injection.
cleanHtmlString()  : string
Creates an "escape string" to help prevent SQL injection - doesn't strip HTML tags.

Functions

connect()

Connects to a database.

connect([string $server = DBSERVER ][, string $username = DBUSER ][, string $password = DBPASS ][, string $databaseName = DBNAME ], int $port[, string $socket = "" ]) : mysqli
Parameters
$server : string = DBSERVER

(Optional) The database server's hostname (Defaults to DBSERVER).

$username : string = DBUSER

(Optional) The database user (Defaults to DBUSER).

$password : string = DBPASS

(Optional) The database user's password (Defaults to DBPASS).

$databaseName : string = DBNAME

(Optional) The database name (Defaults to DBNAME).

$port : int

(Optional) The database port.

$socket : string = ""

(Optional) The database socket.

Return values
mysqli

The database connection object.

disconnect()

Closes an open database connection.

disconnect(mysqli $dBConnection) : void
Parameters
$dBConnection : mysqli

The Database connection object.

Return values
void

cleanString()

Creates an "escape string" to help prevent SQL injection.

cleanString(mysqli $dBConnection, string $string[, string $encoding = "UTF-8" ]) : string

This method will convert HTML to escape sequences.

Parameters
$dBConnection : mysqli

The database connection object currently in use.

$string : string

The String to clean.

$encoding : string = "UTF-8"

(Optional) the encoding of the string (Defaults to UTF-8).

Return values
string

The string.

cleanHtmlString()

Creates an "escape string" to help prevent SQL injection - doesn't strip HTML tags.

cleanHtmlString(mysqli $dBConnection, string $string[, string $encoding = "UTF-8" ]) : string
Parameters
$dBConnection : mysqli

The database connection object currently in use.

$string : string

The String to clean.

$encoding : string = "UTF-8"

(Optional) the encoding of the string (Defaults to UTF-8).

Return values
string

The string.

Search results