reference/mysqli/functions/mysqli-connect.xml
be526864c9777106cd78a517628847b60743e2d4
...
...
@@ -11,44 +11,13 @@
11
11
<para>
12
12
&info.function.alias; <methodname>mysqli::__construct</methodname>
13
13
</para>
14
-
<para>
15
-
Although the <methodname>mysqli::__construct</methodname> documentation also includes
16
-
procedural examples that use the <function>mysqli_connect</function> function, here
17
-
is a short example:
18
-
</para>
19
-
</refsect1>
20
-

21
-
<refsect1 role="examples">
22
-
&reftitle.examples;
23
-
<example>
24
-
<title><function>mysqli_connect</function> example</title>
25
-
<programlisting role="php">
26
-
<![CDATA[
27
-
<?php
28
-
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");
29
-

30
-
if (!$link) {
31
-
echo "Error: Unable to connect to MySQL." . PHP_EOL;
32
-
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
33
-
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
34
-
exit;
35
-
}
36
-

37
-
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
38
-
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
39
-

40
-
mysqli_close($link);
41
-
?>
42
-
]]>
43
-
</programlisting>
44
-
&examples.outputs.similar;
45
-
<screen>
46
-
<![CDATA[
47
-
Success: A proper connection to MySQL was made! The my_db database is great.
48
-
Host information: localhost via TCP/IP
49
-
]]>
50
-
</screen>
51
-
</example>
14
+
<note>
15
+
<para>
16
+
If mysqli exception mode is not enabled and a connection fails,
17
+
then <function>mysqli_connect</function> returns &false; instead of an object.
18
+
The <function>mysqli_connect_error</function> function can be used to fetch the connection error.
19
+
</para>
20
+
</note>
52
21
</refsect1>
53
22
</refentry>
54
23

...
...
@@ -72,4 +41,3 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
72
41
vim: et tw=78 syn=sgml
73
42
vi: ts=1 sw=1
74
43
-->
75
-

76
44