reference/mysqli/mysqli/connect-error.xml
104bc5c203adbc75f7c71960bb18b2b71c889b45
...
...
@@ -4,24 +4,28 @@
4
4
<refnamediv>
5
5
<refname>mysqli::$connect_error</refname>
6
6
<refname>mysqli_connect_error</refname>
7
-
<refpurpose>Returns a string description of the last connect error</refpurpose>
7
+
<refpurpose>Returns a description of the last connection error</refpurpose>
8
8
</refnamediv>
9
9

10
10
<refsect1 role="description">
11
11
&reftitle.description;
12
12
<para>&style.oop;</para>
13
-
<fieldsynopsis><type>string</type><varname linkend="mysqli.connect-error">mysqli->connect_error</varname></fieldsynopsis>
13
+
<fieldsynopsis><type class="union"><type>string</type><type>null</type></type><varname linkend="mysqli.connect-error">mysqli-&gt;connect_error</varname></fieldsynopsis>
14
14
<para>&style.procedural;</para>
15
15
<methodsynopsis>
16
-
<type>string</type><methodname>mysqli_connect_error</methodname>
17
-
<void />
16
+
<type class="union"><type>string</type><type>null</type></type><methodname>mysqli_connect_error</methodname>
17
+
<void/>
18
18
</methodsynopsis>
19
19
<para>
20
-
Returns the last error message string from the last call to
21
-
<function>mysqli_connect</function>.
20
+
Returns the error message from the last connection attempt.
22
21
</para>
23
22
</refsect1>
24
23

24
+
<refsect1 role="parameters">
25
+
&reftitle.parameters;
26
+
&no.function.parameters;
27
+
</refsect1>
28
+
25
29
<refsect1 role="returnvalues">
26
30
&reftitle.returnvalues;
27
31
<para>
...
...
@@ -32,53 +36,38 @@
32
36
<refsect1 role="examples">
33
37
&reftitle.examples;
34
38
<example>
35
-
<title><varname>$mysqli->connect_error</varname> example</title>
39
+
<title><varname>$mysqli-&gt;connect_error</varname> example</title>
36
40
<para>&style.oop;</para>
37
41
<programlisting role="php">
38
42
<![CDATA[
39
43
<?php
40
-
$mysqli = @new mysqli('localhost', 'fake_user', 'my_password', 'my_db');
41
44

42
-
// Works as of PHP 5.2.9 and 5.3.0.
45
+
mysqli_report(MYSQLI_REPORT_OFF);
46
+
/* @ is used to suppress warnings */
47
+
$mysqli = @new mysqli('localhost', 'fake_user', 'wrong_password', 'does_not_exist');
43
48
if ($mysqli->connect_error) {
44
-
die('Connect Error: ' . $mysqli->connect_error);
49
+
/* Use your preferred error logging method here */
50
+
error_log('Connection error: ' . $mysqli->connect_error);
45
51
}
46
-
?>
47
52
]]>
48
53
</programlisting>
49
54
<para>&style.procedural;</para>
50
55
<programlisting role="php">
51
56
<![CDATA[
52
57
<?php
53
-
$link = @mysqli_connect('localhost', 'fake_user', 'my_password', 'my_db');
54
58

59
+
mysqli_report(MYSQLI_REPORT_OFF);
60
+
/* @ is used to suppress warnings */
61
+
$link = @mysqli_connect('localhost', 'fake_user', 'wrong_password', 'does_not_exist');
55
62
if (!$link) {
56
-
die('Connect Error: ' . mysqli_connect_error());
63
+
/* Use your preferred error logging method here */
64
+
error_log('Connection error: ' . mysqli_connect_error());
57
65
}
58
-
?>
59
66
]]>
60
67
</programlisting>
61
-
&examples.outputs;
62
-
<screen>
63
-
<![CDATA[
64
-
Connect Error: Access denied for user 'fake_user'@'localhost' (using password: YES)
65
-
]]>
66
-
</screen>
67
68
</example>
68
69
</refsect1>
69
70

70
-
<refsect1 role="notes">
71
-
&reftitle.notes;
72
-
<warning>
73
-
<para>
74
-
The mysqli-&gt;connect_error property only works properly
75
-
as of PHP versions 5.2.9 and 5.3.0.
76
-
Use the <function>mysqli_connect_error</function>
77
-
function if compatibility with earlier PHP versions is required.
78
-
</para>
79
-
</warning>
80
-
</refsect1>
81
-

82
71
<refsect1 role="seealso">
83
72
&reftitle.seealso;
84
73
<para>
...
...
@@ -93,7 +82,6 @@ Connect Error: Access denied for user 'fake_user'@'localhost' (using password: Y
93
82
</refsect1>
94
83

95
84
</refentry>
96
-

97
85
<!-- Keep this comment at the end of the file
98
86
Local variables:
99
87
mode: sgml
100
88