PHP MySQLi Database Connection

PHP MySQLi Database Connection

Today, We want to share with you PHP MySQLi Database Connection.
In this post we will show you PHP Connect to MySQLi, hear for database – PHP mysqli connect function we will give you demo and example for implement.
In this post, we will learn about How to use MySQLi_connect in PHP with an example.

Simple Means MySQLi is improved and bettar then mysql or PHP extension of MySQL which is introduced in PHP 5 version.

The MySQLi {used in database relational } Extension (main futures is MySQL Improved) is a relational database driver supported used in the core or (OOP) PHP programming language to provide an simple interface with using MySQL databases.

MySQLi – The i standing for ‘improved’.

PHP MySQLi – Connecting

Connecting is as simple(mysqli php version) as just instantiating a new instance of MySQLi

 

PHP MySQLi – Querying

query("SELECT * FROM `users` WHERE username='$username' AND `password` = '$pass_encrypt'");
?>

PHP MySQLi – Output query results

fetch_assoc()){
    echo $result['username'] . '
'; } ?>

PHP MySQLi – Number of returned rows

query("SELECT * FROM `users` WHERE username='$username' AND `password` = '$pass_encrypt'");
$count=mysqli_num_rows($fetch);
if($count==1) :
   $row=mysqli_fetch_array($fetch);
   $_SESSION['login_username']=$row['username'];    
   echo 1;  
else :
  echo 0;
endif;
?>

List Of PHP 5 MySQLi Functions

Function Description
mysqli_affected_rows() This Function result returns of the the number of total affected rows in the previous used MySQL operation
mysqli_autocommit() Turns on or off like as a boolean auto-committing database simple modifications
mysqli_change_user() Changes the user of the specified simple database connection
mysqli_character_set_name() This Function result returns of the the default character set for the database connection
mysqli_close() Closes a previously opened database connection
mysqli_commit() Commits the current transaction
mysqli_connect_errno() This Function result returns of the the error code from the last connect call
mysqli_connect_error() This Function result returns of the the error description from the last connection error
mysqli_connect() Opens a new connection to the MySQL server
mysqli_data_seek() Adjusts the result pointer to an arbitrary row in the result-set
mysqli_debug() Performs debugging operations
mysqli_dump_debug_info() Dump debugging information into the log
mysqli_errno() This Function result returns of the the error code for the most recent function call
mysqli_error_list() This Function result returns of the a array of errors for the most recent MySQLi function call
mysqli_error() This Function result returns of the the last error message for the most recent MySQLi function call
mysqli_fetch_all() Fetches all result rows as an associative array, a numeric array, or both
mysqli_fetch_array() Fetches a result row as an associative, a numeric array, or both
mysqli_fetch_assoc() Fetches a result row as an associative array
mysqli_fetch_field_direct() Fetch meta-data for a single field as an object
mysqli_fetch_field() This Function result returns of the the next field in the result set, as an object
mysqli_fetch_fields() This Function result returns of the an array of objects representing the fields in a result set
mysqli_fetch_lengths() This Function result returns of the the lengths of the columns of the current row in the result set
mysqli_fetch_object() This Function result returns of the the current row of a result set as an object
mysqli_fetch_row() Fetches one row of data from the result set and This Function result returns of the it as an enumerated array
mysqli_field_count() This Function result returns of the the number of columns for the most recent query
mysqli_field_seek() Sets the result pointer to a specified field offset
mysqli_field_tell() This Function result returns of the the position of the field cursor used for the last mysqli_fetch_field() call
mysqli_free_result() Frees the memory associated with a result
mysqli_get_charset() This Function result returns of the a character set object
mysqli_get_client_info() This Function result returns of the the MySQL client version as a string
mysqli_get_client_stats() This Function result returns of the client per-process statistics.
mysqli_get_client_version() This Function result returns of the the MySQL client version as an integer
mysqli_get_connection_stats() This Function result returns of the client connection statistics.
mysqli_get_host_info() This Function result returns of the a string representing the type of connection used including the MySQL server hostname
mysqli_get_proto_info() This Function result returns of the the version of the MySQL protocol used
mysqli_get_server_info() This Function result returns of the the version of the MySQL server
mysqli_get_server_version() This Function result returns of the the version of the MySQL server as an integer
mysqli_info() This Function result returns of the information about the last query executed
mysqli_init() Initializes MySQLi and This Function result returns of the a resource for use with mysqli_real_connect()
mysqli_insert_id() This Function result returns of the the auto-generated id used in the last query
mysqli_kill() Asks the server to kill a MySQL thread
mysqli_more_results() Check if there are any more query results from a multi query
mysqli_multi_query() Performs one or multiple queries on the database
mysqli_next_result() Prepares the next result set from mysqli_multi_query()
mysqli_num_fields() This Function result returns of the the number of fields in a result set
mysqli_num_rows() This Function result returns of the the number of rows in a result set
mysqli_options() Sets extra connect options and affect behavior for a connection
mysqli_ping() Pings a server connection, or tries to reconnect if the connection has gone down
mysqli_prepare() Prepares an SQL statement for execution
mysqli_query() Performs a query on the database
mysqli_real_connect() Opens a connection to a mysql server
mysqli_real_escape_string() Escapes special characters in a string for use in an SQL statement
mysqli_real_query() Executes an SQL query
mysqli_refresh() Refreshes tables or caches, or resets the replication server information
mysqli_rollback() Rollbacks the current transaction for the database
mysqli_select_db() Selects the default database for database queries
mysqli_set_charset() Sets the default client character set
mysqli_set_local_infile_default() Unsets user defined handler for load local infile command
mysqli_set_local_infile_handler() Set callback function for LOAD DATA LOCAL INFILE command
mysqli_sqlstate() This Function result returns of the the SQLSTATE error code from the previous MySQL operation
mysqli_ssl_set() Used to establish secure connections using SSL
mysqli_stat() This Function result returns of the the current system status
mysqli_stmt_init() Initializes a statement and This Function result returns of the an object for use with mysqli_stmt_prepare()
mysqli_store_result() Transfers a result set from the last query
mysqli_thread_id() This Function result returns of the the thread ID for the current connection
mysqli_thread_safe() This Function result returns of the whether the client library is compiled as thread-safe
mysqli_use_result() Initiates the retrieval of a result set from the last query executed using the mysqli_real_query()
mysqli_warning_count() This Function result returns of the the number of warnings from the last query in the connection

MySQLi

Leave a Comment