Hướng dẫn mysqli_connect exception
mysqli::connectmysqli_connect(PHP 5, PHP 7, PHP 8) mysqli::__construct -- mysqli::connect -- mysqli_connect — Open a new connection to the MySQL server DescriptionObject-oriented style public mysqli::__construct( public mysqli::connect( mysqli_connect( Parametershostname Can be either a host name or an IP address. The local host is assumed when passing the Prepending host by username The MySQL user name. password If not provided or database If provided will specify the default database to be used when performing queries. port Specifies the port number to attempt to connect to the MySQL server. socket Specifies the socket or named pipe that should be used.
Return Valuesmysqli::__construct() always returns an object which represents the connection to a MySQL Server, regardless of it being successful or not. mysqli_connect() returns an object which represents the connection to a MySQL Server, or mysqli::connect() returns Errors/Exceptions If ExamplesExample #1 mysqli::__construct() example Object-oriented style
Procedural style
The above examples will output something similar to: Success... localhost via TCP/IP Example #2 Extending mysqli class
Example #3 Manual error handling If error reporting is disabled, the developer is responsible for checking and handling failures Object-oriented style
(0); Procedural style
(0); Notes
See Also
fugyl13 at gmail dot com ¶ 8 years ago
andres at 21brains dot com ¶ 8 years ago
php at haravikk dot me ¶ 4 years ago
chris at ocproducts dot com ¶ 5 years ago
paul at mtnlist dot com ¶ 9 years ago
PaulieG ¶ 6 years ago
Anonymous ¶ 13 years ago
Ben ¶ 7 years ago
webmaster at aryes dot fr ¶ 7 years ago
linguafranca2003 at yahoo dot com ¶ 7 years ago
$db->connect_error) { oleg at mastak dot fi ¶ 9 years ago
|