Get the App
SLTechnology News&Howtos  ›  Development  › 

How php prints database error messages

Shulou Source: shulou.com Published: 2022-06-03 10:04:25 10月18日 Update

In this issue, the editor will bring you about how php prints database error messages. The article is rich in content and analyzes and narrates it from a professional perspective. I hope you can get something after reading this article.

Php print database error message method: 1, create a PHP sample file; 2, connect to the database through mysql_connect; 3, print database error message through mysql_error function.

This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer.

How does php print database error messages?

The code is as follows:

$link = @ mysql_connect ("server", "account", "password") or die ("own error interpretation" .mysql _ error ()); echo mysql_error (); / / print data error message

Related introduction:

Mysql_error

(PHP 4, PHP 5)

Mysql_error-returns the text error message generated by the previous MySQL operation

Description

Mysql_error (resource $link_identifier =?): string

Returns the error text of the previous MySQL function, or''(empty string) if there is no error. If the connection resource number is not specified, the error message is extracted from the MySQL server using the last successful connection.

Errors from the back end of the MySQL database no longer issue warnings, and mysql_error () is used to extract the error text. Note that this function only returns the error text of the last execution of the MySQL function (excluding mysql_error () and mysql_errno ()), so if you want to use this function, be sure to check its value before calling another MySQL function.

Mysqli_error ()

The mysqli_error () function returns the last error description of the recently called function.

Grammar

Mysqli_error (connection)

Parameters.

Connection is required. Specifies the MySQL connection to be used.

Return value: returns a string with an error description. Returns "" if no error occurs.

PHP version: 5 +

The above is the editor for you to share the php how to print database error messages, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Error information data function database text content server analysis service success professional medium and small code rich in content parameters characters strings passwords that is Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker macOS MySQL NVidia