mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
* Add oop example and tweak procedural example to match connect examples.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@277057 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
5b320c16b0
commit
3c2bce9c03
2 changed files with 59 additions and 24 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<refentry xml:id="mysqli.connect-errno" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>mysqli->connect_errno</refname>
|
||||
|
@ -42,23 +42,40 @@
|
|||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>mysqli_connect_errno</function> example</title>
|
||||
<programlisting role="php">
|
||||
<example>
|
||||
<title>Object oriented style</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$mysqli = @new mysqli('localhost', 'fake_user', 'my_password', 'my_db');
|
||||
|
||||
$link = @mysqli_connect("localhost", "nonexisting_user", "");
|
||||
|
||||
if (!$link) {
|
||||
printf("Can't connect to localhost. Errorcode: %d\n", mysqli_connect_errno());
|
||||
if ($mysqli->connect_errno) {
|
||||
die('Connect Error: ' . $mysqli->connect_errno);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = @mysqli_connect('localhost', 'fake_user', 'my_password', 'my_db');
|
||||
|
||||
if (!$link) {
|
||||
die('Connect Error: ' . mysqli_connect_errno());
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Connect Error: 1045
|
||||
]]>
|
||||
</screen>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<refentry xml:id="mysqli.connect-error" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>mysqli->connect_error</refname>
|
||||
|
@ -32,23 +32,41 @@
|
|||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>mysqli_connect_error</function> example</title>
|
||||
<programlisting role="php">
|
||||
<example>
|
||||
<title>Object oriented style</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$mysqli = @new mysqli('localhost', 'fake_user', 'my_password', 'my_db');
|
||||
|
||||
$link = @mysqli_connect("localhost", "nonexisting_user", "");
|
||||
|
||||
if (!$link) {
|
||||
printf("Can't connect to localhost. Error: %s\n", mysqli_connect_error());
|
||||
// Works as of PHP 5.2.9 and 5.3.0RC1.
|
||||
if ($mysqli->connect_error) {
|
||||
die('Connect Error: ' . $mysqli->connect_error);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>Procedural style</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$link = @mysqli_connect('localhost', 'fake_user', 'my_password', 'my_db');
|
||||
|
||||
if (!$link) {
|
||||
die('Connect Error: ' . mysqli_connect_error());
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Connect Error: Access denied for user 'fake_user'@'localhost' (using password: YES)
|
||||
]]>
|
||||
</screen>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="notes">
|
||||
|
|
Loading…
Reference in a new issue