PHP mysql_info() Function

Definition and Usage

The mysql_info() function returns information about the most recent query.

If successful, returns information about the statement; if failed, returns false.

Syntax

mysql_info(connection)
Parameters Description
connection Optional. Specifies the MySQL connection. If not specified, the previous connection is used.

description

mysql_info() returns the given connection details of the latest query performed. If no specific connectionis assumed to be the last opened connection.

mysql_info() returns a string for all the following statements listed:

INSERT INTO ... SELECT ...
INSERT INTO ... VALUES (...),(...),(...)...
LOAD DATA INFILE ...
ALTER TABLE
UPDATE

Returns false for any other statements. The format of the string depends on the given statement.

Example

<?php
$con = mysql_connect("localhost", "hello", "321");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
$db_selected = mysql_select_db("test_db",$con);
$sql = "INSERT INTO person VALUES ('Bill','Gates','Utah','19')";
$result = mysql_query($sql,$con);
$info = mysql_info($con);
echo $info;
mysql_close($con);
?>

Output similar to:

String format: Records: 15 Duplicates: 0 Warnings: 0