mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 08:28:54 +00:00
Modernize examples on connect_error & connect_errno (#1454)
This commit is contained in:
parent
e9df25bfee
commit
104bc5c203
2 changed files with 12 additions and 20 deletions
|
@ -42,9 +42,10 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/* @ is used to suppress default error messages */
|
||||
$mysqli = @new mysqli('localhost', 'fake_user', 'my_password', 'my_db');
|
||||
|
||||
mysqli_report(MYSQLI_REPORT_OFF);
|
||||
/* @ is used to suppress warnings */
|
||||
$mysqli = @new mysqli('localhost', 'fake_user', 'wrong_password', 'does_not_exist');
|
||||
if ($mysqli->connect_errno) {
|
||||
/* Use your preferred error logging method here */
|
||||
error_log('Connection error: ' . $mysqli->connect_errno);
|
||||
|
@ -55,21 +56,16 @@ if ($mysqli->connect_errno) {
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/* @ is used to suppress default error messages */
|
||||
$link = @mysqli_connect('localhost', 'fake_user', 'my_password', 'my_db');
|
||||
|
||||
mysqli_report(MYSQLI_REPORT_OFF);
|
||||
/* @ is used to suppress warnings */
|
||||
$link = @mysqli_connect('localhost', 'fake_user', 'wrong_password', 'does_not_exist');
|
||||
if (!$link) {
|
||||
/* Use your preferred error logging method here */
|
||||
error_log('Connection error: ' . mysqli_connect_errno());
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
&examples.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Connection error: 1045
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
|
|
@ -41,9 +41,10 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/* @ is used to suppress default error messages */
|
||||
$mysqli = @new mysqli('localhost', 'fake_user', 'my_password', 'my_db');
|
||||
|
||||
mysqli_report(MYSQLI_REPORT_OFF);
|
||||
/* @ is used to suppress warnings */
|
||||
$mysqli = @new mysqli('localhost', 'fake_user', 'wrong_password', 'does_not_exist');
|
||||
if ($mysqli->connect_error) {
|
||||
/* Use your preferred error logging method here */
|
||||
error_log('Connection error: ' . $mysqli->connect_error);
|
||||
|
@ -54,21 +55,16 @@ if ($mysqli->connect_error) {
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/* @ is used to suppress default error messages */
|
||||
$link = @mysqli_connect('localhost', 'fake_user', 'my_password', 'my_db');
|
||||
|
||||
mysqli_report(MYSQLI_REPORT_OFF);
|
||||
/* @ is used to suppress warnings */
|
||||
$link = @mysqli_connect('localhost', 'fake_user', 'wrong_password', 'does_not_exist');
|
||||
if (!$link) {
|
||||
/* Use your preferred error logging method here */
|
||||
error_log('Connection error: ' . mysqli_connect_error());
|
||||
}
|
||||
]]>
|
||||
</programlisting>
|
||||
&examples.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Connection error: Access denied for user 'fake_user'@'localhost' (using password: YES)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
|
Loading…
Reference in a new issue