PHP mysqli real_query() Function

❮ PHP MySQLi Reference

Example - Object Oriented style

Execute a single SQL query. Store the result with store_result():

<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");

// Check connection
if ($mysqli -> connect_errno) {
  echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
  exit();
}

$mysqli -> real_query("SELECT * FROM Persons");

if ($mysqli -> field_count) {
  $result = $mysqli -> store_result();
  $row = $result -> fetch_row();
  // Free result set
  $result -> free_result();
}

$mysqli -> close();
?>


Definition and Usage

The real_query() / mysqli_real_query() function executes a single SQL query. The result can be retrieved or stored with the store_result() or use_result() functions.


Syntax

Object oriented style:

$mysqli -> real_query(query)

Procedural style:

mysqli_real_query(connection, query)

Parameter Values

Parameter Description
connection Required. Specifies the MySQL connection to use
query Required. The query to be executed

Technical Details

Return Value: TRUE on success. FALSE on failure
PHP Version: 5+

❮ PHP MySQLi Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.