IBM

functions.inc

<?
   //
   // This material contains IBM copyrighted sample programming source
   // code DB2(R) UDB PHP Demo.  IBM grants you a nonexclusive copyright
   // license to use the Sample Code as an example from which you can
   // generate similar function tailored to your own specific needs.
   // Your license to this Sample Code provides you no right or licenses
   // to any IBM patents.
   //
   // The Sample Code is provided by IBM for illustrative purposes
   // only.  The Sample Code has not been thoroughly tested under
   // all conditions.  IBM, therefore, does not  guarantee or imply
   // its reliability, serviceability, or function.  IBM provides
   // no program services for the Sample Code.
   //
   // All Sample Code contained herein is provided to you "AS IS" without
   // any warranties of any kind. THE IMPLIED WARRANTIES OF
   // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
   // AND NON-INFRINGMENT ARE EXPRESSLY DISCLAIMED.  SOME
   // JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED
   // WARRANTIES, SO THE ABOVE EXCLUSIONS MAY NOT APPLY
   // TO YOU.  IN NO EVENT WILL IBM BE LIABLE TO ANY PARTY
   // FOR ANY DIRECT, INDIRECT, SPECIAL OR OTHER CONSEQUENTIAL
   // DAMAGES FOR ANY USE OF THE SAMPLE CODE INCLUDING,
   // WITHOUT LIMITATION, ANY LOST PROFITS, BUSINESS
   // INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON
   // YOUR INFORMATION HANDLING SYSTEM OR OTHERWISE,
   // EVEN IF WE ARE EXPRESSLY ADVISED OF THE POSSIBILITY
   // OF SUCH DAMAGES.
   //
   // (C) Copyright IBM CORP. 2001
   // All rights reserved.
   // US Government Users Restricted Rights -
   // Use, duplication or disclosure restricted
   // by GSA ADP Schedule Contract with IBM Corp.
   // Licensed Material - Property of IBM

   //////////////////////////////////////////////////////////////
   // iSeries Linux DB2/PHP/ODBC Demo
   // Written by Dave Boutcher (boutcher@us.ibm.com)
   //////////////////////////////////////////////////////////////
   // This PHP include defines some standard functions we use
   //////////////////////////////////////////////////////////////

// Put a fancy button up that changes when it's moused over
function buttonref($class, $link, $data) {
echo "<tr><td class=$class height=40 width=130 align=center valign=center ".
     "style=\"filter:alpha(opacity=50)\" onMouseover=\"makevisible(this,0)\" ".
     "onMouseout=\"makevisible(this,1)\" >".
     "<a class=bright href=\"$link\">$data</a></td></tr>";
}

// Check the result of an SQL statement and put up an error message if something
// bad happened
function checksql($result) {
   if (!$result) {
      include("html_tophdr.inc");
      echo "<td><h1 align=center>SQL Error</h1>";
      echo "<table align=center bgcolor=\"red\"><tr><td>";
      echo "A database error occurred";
      if (isset($isdb_database)) echo " in database $isdb_database";
      if (isset($isdb_system)) echo " on $isdb_system";
      echo "</td></tr>";
      echo "<tr><td>The SQL error text is: ".db2_stmt_errormsg() ."</td></tr>";
      echo "<tr><td>The SQL error code is ".db2_stmt_error() ."</td></tr>";
      echo "</table>";

      $isPase = (PHP_OS == "AIX" || PHP_OS == "OS400");
      if (db2_stmt_error() == "S0002" || ($isPase && db2_stmt_error() == "42704")) {
         echo "<p align=center>A likely cause of this error is that the schema on the ".
              "iSeries system does not exist.  If you would like to try and ".
              "create it, press this button.  <p>NOTE: Creating the sample schema takes a few seconds!";
          echo "<p align=center><form method=\"POST\" action=\"createdb.php\">".
               "<input type=\"submit\" name=\"action\" value=\"Create\">";
      }
      echo "<p align=center><form method=\"POST\" action=\"index.php\">".
           "<input type=\"submit\" name=\"action\" value=\"Retry\">";
      include("html_mainftr.inc");
      exit;
   }
}

?>

Source for this page: showsource.php