Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 2510

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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>Returns the last connection error message and SQLCODE value</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.db2-conn-error.html">db2_conn_error</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.db2-connect.html">db2_connect</a></div>
 <div class="up"><a href="ref.ibm-db2.html">IBM DB2 Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.db2-conn-errormsg" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">db2_conn_errormsg</h1>
  <p class="verinfo">(PECL ibm_db2 &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">db2_conn_errormsg</span> &mdash; <span class="dc-title">
   Returns the last connection error message and SQLCODE value
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.db2-conn-errormsg-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> <span class="methodname"><strong>db2_conn_errormsg</strong></span>
    ([ <span class="methodparam"><span class="type">resource</span> <code class="parameter">$connection</code></span>
  ] )</div>


  <p class="para rdfs-comment">
    <span class="function"><strong>db2_conn_errormsg()</strong></span> returns an error message and SQLCODE
   value representing the reason the last database connection attempt failed.
   As  <span class="function"><a href="function.db2-connect.html" class="function">db2_connect()</a></span> returns <strong><code>FALSE</code></strong> in the event of a failed
   connection attempt, do not pass any parameters to
    <span class="function"><strong>db2_conn_errormsg()</strong></span> to retrieve the associated error
   message and SQLCODE value.
  </p>
  <p class="para">
   If, however, the connection was successful but becomes invalid over time,
   you can pass the <em><code class="parameter">connection</code></em> parameter to retrieve
   the associated error message and SQLCODE value for a specific connection.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.db2-conn-errormsg-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">connection</code></em></span>
      <dd>

       <p class="para">
        A connection resource associated with a connection that initially
        succeeded, but which over time became invalid.
       </p>
      </dd>

     </dt>

   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.db2-conn-errormsg-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a string containing the error message and SQLCODE value resulting
   from a failed connection attempt. If there is no error associated with the last
   connection attempt,  <span class="function"><strong>db2_conn_errormsg()</strong></span> returns an empty
   string.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.db2-conn-errormsg-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1146">
    <p><strong>Example #1 Retrieving the error message returned by a failed connection attempt</strong></p>
    <div class="example-contents"><p>
     The following example demonstrates how to return an error message and
     SQLCODE value after deliberately passing invalid parameters to
      <span class="function"><a href="function.db2-connect.html" class="function">db2_connect()</a></span>.
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$conn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">db2_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">'badname'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'baduser'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'badpassword'</span><span style="color: #007700">);<br />if&nbsp;(!</span><span style="color: #0000BB">$conn</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;</span><span style="color: #0000BB">db2_conn_errormsg</span><span style="color: #007700">();<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
[IBM][CLI Driver] SQL1013N  The database alias name
or database name &quot;BADNAME&quot; could not be found.  SQLSTATE=42705
 SQLCODE=-1013
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.db2-conn-errormsg-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.db2-conn-error.html" class="function" rel="rdfs-seeAlso">db2_conn_error()</a> - Returns a string containing the SQLSTATE returned by the last connection attempt</span></li>
    <li class="member"> <span class="function"><a href="function.db2-connect.html" class="function" rel="rdfs-seeAlso">db2_connect()</a> - Returns a connection to a database</span></li>
    <li class="member"> <span class="function"><a href="function.db2-stmt-error.html" class="function" rel="rdfs-seeAlso">db2_stmt_error()</a> - Returns a string containing the SQLSTATE returned by an SQL statement</span></li>
    <li class="member"> <span class="function"><a href="function.db2-stmt-errormsg.html" class="function" rel="rdfs-seeAlso">db2_stmt_errormsg()</a> - Returns a string containing the last SQL statement error message</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.db2-conn-error.html">db2_conn_error</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.db2-connect.html">db2_connect</a></div>
 <div class="up"><a href="ref.ibm-db2.html">IBM DB2 Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>