2002-04-15 00:12:54 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2005-03-31 07:47:25 +00:00
|
|
|
<!-- $Revision: 1.17 $ -->
|
2005-03-30 04:07:29 +00:00
|
|
|
<refentry id="function.mysql-error">
|
|
|
|
<refnamediv>
|
|
|
|
<refname>mysql_error</refname>
|
2005-03-30 08:14:56 +00:00
|
|
|
<refpurpose>Returns the text of the error message from previous MySQL operation</refpurpose>
|
2005-03-30 04:07:29 +00:00
|
|
|
</refnamediv>
|
2005-03-30 08:14:56 +00:00
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
&reftitle.description;
|
2005-03-30 06:27:14 +00:00
|
|
|
<methodsynopsis>
|
|
|
|
<type>string</type><methodname>mysql_error</methodname>
|
|
|
|
<methodparam choice="opt"><type>resource</type><parameter>link_identifier</parameter></methodparam>
|
|
|
|
</methodsynopsis>
|
2005-03-30 04:07:29 +00:00
|
|
|
<para>
|
2005-03-30 08:14:56 +00:00
|
|
|
Returns the error text from the last MySQL function.
|
2005-03-30 04:07:29 +00:00
|
|
|
Errors coming back from the MySQL database backend no longer
|
|
|
|
issue warnings. Instead, use <function>mysql_error</function> to
|
|
|
|
retrieve the error text. Note that this function only returns the
|
|
|
|
error text from the most recently executed MySQL function (not
|
|
|
|
including <function>mysql_error</function> and
|
|
|
|
<function>mysql_errno</function>), so if you want to use it, make
|
|
|
|
sure you check the value before calling another MySQL function.
|
2005-03-30 08:14:56 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
&reftitle.parameters;
|
|
|
|
<para>
|
|
|
|
<variablelist>
|
2005-03-31 07:47:25 +00:00
|
|
|
&mysql.linkid.description;
|
2005-03-30 08:14:56 +00:00
|
|
|
</variablelist>
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
<para>
|
|
|
|
Returns the error text from the last MySQL function, or
|
|
|
|
<literal>''</literal> (empty string) if no error occurred.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
&reftitle.examples;
|
|
|
|
<para>
|
2005-03-30 04:07:29 +00:00
|
|
|
<example>
|
|
|
|
<title><function>mysql_error</function> example</title>
|
|
|
|
<programlisting role="php">
|
2002-04-15 00:12:54 +00:00
|
|
|
<![CDATA[
|
|
|
|
<?php
|
2004-01-05 13:03:26 +00:00
|
|
|
$link = mysql_connect("localhost", "mysql_user", "mysql_password");
|
2002-04-21 13:47:45 +00:00
|
|
|
|
2004-01-05 13:03:26 +00:00
|
|
|
mysql_select_db("nonexistentdb", $link);
|
|
|
|
echo mysql_errno($link) . ": " . mysql_error($link). "\n";
|
2002-04-21 13:47:45 +00:00
|
|
|
|
2004-01-05 13:03:26 +00:00
|
|
|
mysql_select_db("kossu", $link);
|
|
|
|
mysql_query("SELECT * FROM nonexistenttable", $link);
|
|
|
|
echo mysql_errno($link) . ": " . mysql_error($link) . "\n";
|
2002-04-15 00:12:54 +00:00
|
|
|
?>
|
|
|
|
]]>
|
2005-03-30 04:07:29 +00:00
|
|
|
</programlisting>
|
2005-03-30 08:14:56 +00:00
|
|
|
&example.outputs.similar;
|
|
|
|
<screen>
|
2002-04-21 13:47:45 +00:00
|
|
|
<![CDATA[
|
|
|
|
1049: Unknown database 'nonexistentdb'
|
|
|
|
1146: Table 'kossu.nonexistenttable' doesn't exist
|
|
|
|
]]>
|
2005-03-30 08:14:56 +00:00
|
|
|
</screen>
|
2005-03-30 04:07:29 +00:00
|
|
|
</example>
|
|
|
|
</para>
|
2005-03-30 08:14:56 +00:00
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
&reftitle.seealso;
|
2005-03-30 04:07:29 +00:00
|
|
|
<para>
|
2005-03-30 08:14:56 +00:00
|
|
|
<simplelist>
|
|
|
|
<member><function>mysql_errno</function></member>
|
|
|
|
<member><ulink url="&url.mysql.docs.error;">MySQL error codes</ulink></member>
|
|
|
|
</simplelist>
|
2005-03-30 04:07:29 +00:00
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|
2002-04-15 00:12:54 +00:00
|
|
|
|
|
|
|
<!-- 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
|
|
|
|
-->
|