Added a mysqli_connect() example, now all old user comments here can be deleted

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@337725 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2015-09-03 02:52:40 +00:00
parent 15d053993d
commit 94c2782c41

View file

@ -11,8 +11,45 @@
<para>
&info.function.alias; <methodname>mysqli::__construct</methodname>
</para>
<para>
Although the <methodname>mysqli::__construct</methodname> documentation also includes
procedural examples that use the <function>mysqli_connect</function> function, here
is a short example:
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title><function>mysqli_connect</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("127.0.0.1", "my_user", "my_password", "my_db");
if (!$link) {
echo "Error: Unable to connect to MySQL." . PHP_EOL;
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
exit;
}
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL;
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL;
mysqli_close($link);
?>
]]>
</programlisting>
&examples.outputs;
<screen>
<![CDATA[
Success: A proper connection to MySQL was made! The my_db database is great.
Host information: localhost via TCP/IP
]]>
</screen>
</example>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file