<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Return the LDAP error number of the last LDAP command</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ldap-err2str.html">ldap_err2str</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ldap-error.html">ldap_error</a></div> <div class="up"><a href="ref.ldap.html">LDAP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="function.ldap-errno" class="refentry"> <div class="refnamediv"> <h1 class="refname">ldap_errno</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">ldap_errno</span> — <span class="dc-title">Return the LDAP error number of the last LDAP command</span></p> </div> <div class="refsect1 description" id="refsect1-function.ldap-errno-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">int</span> <span class="methodname"><strong>ldap_errno</strong></span> ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$link_identifier</code></span> )</div> <p class="para rdfs-comment"> Returns the standardized error number returned by the last LDAP command. This number can be converted into a textual error message using <span class="function"><a href="function.ldap-err2str.html" class="function">ldap_err2str()</a></span>. </p> </div> <div class="refsect1 parameters" id="refsect1-function.ldap-errno-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">link_identifier</code></em></span> <dd> <p class="para"> An LDAP link identifier, returned by <span class="function"><a href="function.ldap-connect.html" class="function">ldap_connect()</a></span>. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-function.ldap-errno-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Return the LDAP error number of the last LDAP command for this link. </p> </div> <div class="refsect1 examples" id="refsect1-function.ldap-errno-examples"> <h3 class="title">Examples</h3> <p class="para"> Unless you lower your warning level in your <var class="filename">php.ini</var> sufficiently or prefix your LDAP commands with @ (at) characters to suppress warning output, the errors generated will also show up in your HTML output. <div class="example" id="example-4397"> <p><strong>Example #1 Generating and catching an error</strong></p> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /></span><span style="color: #FF8000">// This example contains an error, which we will catch.<br /></span><span style="color: #0000BB">$ld </span><span style="color: #007700">= </span><span style="color: #0000BB">ldap_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$bind </span><span style="color: #007700">= </span><span style="color: #0000BB">ldap_bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// syntax error in filter expression (errno 87),<br />// must be "objectclass=*" to work.<br /></span><span style="color: #0000BB">$res </span><span style="color: #007700">= @</span><span style="color: #0000BB">ldap_search</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">, </span><span style="color: #DD0000">"o=Myorg, c=DE"</span><span style="color: #007700">, </span><span style="color: #DD0000">"objectclass"</span><span style="color: #007700">);<br />if (!</span><span style="color: #0000BB">$res</span><span style="color: #007700">) {<br /> echo </span><span style="color: #DD0000">"LDAP-Errno: " </span><span style="color: #007700">. </span><span style="color: #0000BB">ldap_errno</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">) . </span><span style="color: #DD0000">"<br />\n"</span><span style="color: #007700">;<br /> echo </span><span style="color: #DD0000">"LDAP-Error: " </span><span style="color: #007700">. </span><span style="color: #0000BB">ldap_error</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">) . </span><span style="color: #DD0000">"<br />\n"</span><span style="color: #007700">;<br /> die(</span><span style="color: #DD0000">"Argh!<br />\n"</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">$info </span><span style="color: #007700">= </span><span style="color: #0000BB">ldap_get_entries</span><span style="color: #007700">(</span><span style="color: #0000BB">$ld</span><span style="color: #007700">, </span><span style="color: #0000BB">$res</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$info</span><span style="color: #007700">[</span><span style="color: #DD0000">"count"</span><span style="color: #007700">] . </span><span style="color: #DD0000">" matching entries.<br />\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span> </span> </code></div> </div> </div> </p> </div> <div class="refsect1 seealso" id="refsect1-function.ldap-errno-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> <span class="function"><a href="function.ldap-err2str.html" class="function" rel="rdfs-seeAlso">ldap_err2str()</a> - Convert LDAP error number into string error message</span></li> <li class="member"> <span class="function"><a href="function.ldap-error.html" class="function" rel="rdfs-seeAlso">ldap_error()</a> - Return the LDAP error message of the last LDAP command</span></li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.ldap-err2str.html">ldap_err2str</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.ldap-error.html">ldap_error</a></div> <div class="up"><a href="ref.ldap.html">LDAP Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>