home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / db2tab.php3.txt < prev    next >
Encoding:
Text File  |  2002-05-06  |  2.7 KB  |  76 lines

  1. <!--
  2. db2tab by Alessandro Grigiante 
  3.  
  4. Simple scripts to access IBM DB2 Universal DataBase tables through PHP ODBC funtions. 
  5. -->
  6.  
  7.  
  8.  
  9. <HTML> 
  10. <BODY TEXT=#FFFFFF BGCOLOR=#000050> 
  11. <HEAD> 
  12. <META HTTP-EQUIV="pragma" CONTENT="no-cache"> 
  13. </HEAD> 
  14. <!-- db2tab.php                                                                   ----> 
  15. <!-- Purpose: Simple scripts to access IBM DB2 Universal DataBase tables through  ----> 
  16. <!--          PHP ODBC funtions.                                                  ----> 
  17. <!-- Author: Alessandro Grigiante  (ale@teknoline.it)                             ----> 
  18. <!-- Copyright: Copyright (C) 2000 Alessandro Grigiante. Subject to the           ----> 
  19. <!--            GNU Public License (GPL) - may be used and modified at will,      ----> 
  20. <!--            so long as license and all attribution is retained.               ----> 
  21. <!-- Disclaimer: Like most free software, no warranty is expressed or implied.    ----> 
  22. <!--             If it doesn't work, feel free to fix it yourself.                ----> 
  23. <!-- Tested on: AIX 4.3.0.0 - IBM DB2 5.3 UDB - Apache/1.3.6 (Unix)  - PHP/3.0.11 ----> 
  24. <!--            Solaris 2.7 - IBM DB2 6.1 UDB - Apache/1.3.11 (Unix) - PHP/4.0b3  ----> 
  25. <!-- Available on: ftp://ftp.teknoline.it/pub/php/db2tab.tar.gz                   ----> 
  26. <!--                                                                              ----> 
  27. <CENTER> 
  28. <FONT SIZE=+2>DB2Tables - List IBM DB2 Universal Data Base Tables with PHP</FONT><BR> 
  29.  
  30. <? 
  31.  include  "db2tab.inc"; 
  32.  
  33. /* ******* Remember to set proper DB2INSTANCE environment variable 
  34.  * Run /your_db2user_home_dir/sqllib/db2profile before to start Apache. 
  35.  * IBM DB2 connection with PHP3/4 over ODBC. 
  36.  * by ale @Mon Sep 13 21:45:29 DFT 1999 
  37.  */ 
  38.  
  39.   $select =  "SELECT TABNAME "; 
  40.   $from   =  "FROM SYSCAT.TABLES "; 
  41.   $where  =  "WHERE TABSCHEMA='$tabschema'"; 
  42.  
  43. /***  Connect to database................. ***/ 
  44.   $c = odbc_pconnect($dbname,$user,$password); 
  45.  
  46.   if ($c > 0) { 
  47.     $query =  $select . $from . $where; 
  48.  
  49. /* Warning................. 
  50.  * Use odbc_exec instead of odbc_prepare + odbc_execute 
  51.  * no bugs and faster. 
  52.  */ 
  53.     $res = odbc_exec($c, $query); 
  54.     $nc=odbc_num_fields($res); 
  55.     $nr=odbc_num_rows($res); 
  56.  
  57.     echo  "<TABLE BORDER=1><TD BGCOLOR=#888888>\n"; 
  58.      /*  Call to create multi switch POST form in HTML */ 
  59.     create_form3($res,$nr,$nc,$act,$c); 
  60.     echo  "</TABLE>\n"; 
  61.  
  62. /* Free all resources and close connection */ 
  63.     odbc_free_result($res); 
  64.     odbc_close($c); 
  65.  
  66.   } else { 
  67.      echo  "BAD CONNECTION Number $c \n"; 
  68.      echo  "--> $php_errormsg \n"; 
  69.   } 
  70.  
  71. ?> 
  72. </CENTER> 
  73. </BODY> 
  74. </HTML> 
  75.  
  76.