downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Alias y Funciones de MySQLi obsoletos> <mysqli_warning::next
[edit] Last updated: Fri, 24 May 2013

view this page in

The mysqli_sql_exception class

(PHP 5)

Introducción

The mysqli exception handling class.

Sinopsis de la Clase

mysqli_sql_exception extends RuntimeException {
/* Propiedades */
protected string $sqlstate ;
/* Propiedades heredadas */
protected string $message ;
protected int $code ;
protected string $file ;
protected int $line ;
}

Propiedades

sqlstate

The sql state with the error.



add a note add a note User Contributed Notes mysqli_sql_exception - [1 notes]
up
0
dronebraindeveloper at gmail dot com
4 months ago
Quick note on how to setup and use mysqli_sql_exceptions properly

<?php
define
("MYSQL_CONN_ERROR", "Unable to connect to database.");

// Ensure reporting is setup correctly
mysqli_report(MYSQLI_REPORT_STRICT);

// Connect function for database access
function connect($usr,$pw,$db,$host) {
   try {
     
$mysqli = new mysqli($host,$usr,$pw,$db);
     
$connected = true;
   } catch (
mysqli_sql_exception $e) {
      throw
$e;
   }
}

try {
 
connect('username','password','database','host');
  echo
'Connected to database';
} catch (
Exception $e) {
  echo
$e->errorMessage();
}
?>

 
show source | credits | sitemap | contact | advertising | mirror sites