php-doc-en/reference/mysqli/functions/mysqli-error.xml

133 lines
3 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.16 $ -->
<refentry id="function.mysqli-error">
<refnamediv>
<refname>mysqli_error</refname>
<refpurpose>Returns a string description of the last error</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<para>Procedural style:</para>
<methodsynopsis>
<type>string</type><methodname>mysqli_error</methodname>
<methodparam><type>mysqli</type><parameter>link</parameter></methodparam>
</methodsynopsis>
<para>Object oriented style (property)</para>
<classsynopsis>
<ooclass><classname>mysqli</classname></ooclass>
<fieldsynopsis><type>string</type><varname>error</varname></fieldsynopsis>
</classsynopsis>
<para>
Returns the last error message for the most recent MySQLi function call
that can succeed or fail.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
&mysqli.link.description;
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A string that describes the error. An empty string if no error occurred.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<example>
<title>Object oriented style</title>
<programlisting role="php">
<![CDATA[
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if (!$mysqli->query("SET a=1")) {
printf("Errormessage: %s\n", $mysqli->error);
}
/* close connection */
$mysqli->close();
?>
]]>
</programlisting>
</example>
<example>
<title>Procedural style</title>
<programlisting role="php">
<![CDATA[
<?php
$link = mysqli_connect("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
if (!mysqli_query($link, "SET a=1")) {
printf("Errormessage: %s\n", mysqli_error($link));
}
/* close connection */
mysqli_close($link);
?>
]]>
</programlisting>
</example>
&example.outputs;
<screen>
<![CDATA[
Errormessage: Unknown system variable 'a'
]]>
</screen>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mysqli_connect_errno</function></member>
<member><function>mysqli_connect_error</function></member>
<member><function>mysqli_errno</function></member>
<member><function>mysqli_sqlstate</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->