How to change or convert MySQL to MySQLi
CODE
<?php
define ('hostnameorservername','localhost'); //Your server name or hostname goes in here
define ('serverusername','root'); //Your database username goes in here
define ('serverpassword',''); //Your database password goes in here
define ('databasenamed','chat'); //Your database name goes in here
$mysqli = new mysqli( hostnameorservername, serverusername, serverpassword, databasenamed );
if ($mysqli->connect_errno)
{
printf("Connection failed: %s\n", $mysqli->connect_error);
exit();
}
if (!$mysqli->set_charset("utf8"))
{
printf("Error loading character set utf8: %s\n", $mysqli->error);
exit();
}
if ( !function_exists('mysql_connect') )
{
function mysql_connect( $sql_host, $sql_username, $sql_password )
{
$mysqli_connect = mysqli_connect( $sql_host, $sql_username, $sql_password );
return $mysqli_connect;
}
}
if ( !function_exists('mysql_select_db') )
{
function mysql_select_db( $database, $connection )
{
$mysqli_select_db = mysqli_select_db( $connection, $database );
return $mysqli_select_db;
}
}
if (!function_exists('mysql_real_escape_string'))
{
function mysql_real_escape_string($string)
{
global $mysqli;
if($string)
{
$real_escape_string = $mysqli->real_escape_string($string);
return $real_escape_string;
}
}
}
if (!function_exists('mysql_query'))
{
function mysql_query($query)
{
global $mysqli;
if($query)
{
$result = $mysqli->query($query);
return $result;
}
}
}
if (!function_exists('mysql_fetch_array'))
{
function mysql_fetch_array($result)
{
if($result)
{
$row = $result->fetch_assoc();
return $row;
}
}
}
if (!function_exists('mysql_num_rows'))
{
function mysql_num_rows($result)
{
if($result)
{
$row_cnt = $result->num_rows;;
return $row_cnt;
}
}
}
if (!function_exists('mysql_free_result'))
{
function mysql_free_result($result)
{
if($result)
{
global $mysqli;
$result->free();
}
}
}
if (!function_exists('mysql_data_seek'))
{
function mysql_data_seek($result, $offset)
{
if($result)
{
global $mysqli;
return $result->data_seek($offset);
}
}
}
if (!function_exists('mysql_close'))
{
function mysql_close()
{
global $mysqli;
return $mysqli->close();
}
}
if (!function_exists('mysql_insert_id'))
{
function mysql_insert_id()
{
global $mysqli;
$lastInsertId = $mysqli->insert_id;
return $lastInsertId;
}
}
if (!function_exists('mysql_error'))
{
function mysql_error()
{
global $mysqli;
$error = $mysqli->error;
return $error;
}
}
?>Screen Shots
Click on a photo below to scroll through the screen shots of the application!
Submit your Job or Project Today!
We can help you turn your idea into reality, take over your existing project, or extend your current development team.
Submit your idea job or project below and we will follow up with you shortly.
OUR OBJECTIVE
Our objective is to reach a place where our services will be highly regarded by businesses from various industrial domains for building their innovative busines solutions with our cutting-edge technological expertise, interactive designs and uncompromised quality.
OUR MISSION
We aspire to help businesses ranging from startups to enterprises, who reach out to us with their requirements, in achieving great lengths, expanding their reach, upscaling their products, and generate a large user-base with our outstanding and cost-effective services.
