× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



> It is sometimes hard to see this stuff
> in a loosely typed language like PHP.
> Joel
> http://www.rpgnext.com

Well, that and the fact this is only my 5th PHP script
ever and the 2nd time I've ever tried to use ODBC. :)

Okay...so here are two scripts that worked for me
running PHP 5 on Apache 1.3 on a W2K machine.

This first script reads the file field format of the
physical file and displays it on the screen:

 <?php
  //Define the connection to the system.
  $odbc = odbc_connect("MYSYSTEM","MYUSERNAME",
"MYPASSWORD") or die;
  
  //Define the library and file name.
  $libname = "MYLIB";
  $filename = "MYFILE";
  
  //Get the data.
  $res400 = odbc_columns($odbc, "MYSYSTEM", $libname,
$filename, "%") or die(odbc_errormsg());
  
  //Display results.
  echo odbc_result_all($res400);
 ?> 


This next script reads the contents of the physical
file and displays it in a table:

 <?php
  //Define the connection to the system.
  $odbc = odbc_connect("MYSYSTEM","MYUSERNAME",
"MYPASSWORD") or die;

  //Define the query.
  $query = "SELECT * FROM MYFILE";

  //Execute the query.
  $queryexe = odbc_exec($odbc, $query) or die;

  //Display the results from the query.
 ?>

<table width="75%" border="1" cellspacing="1"
cellpadding="1" bgcolor="#eeeeee">
 <tr>
  <td><b>Customer Number</b></td>
  <td><b>Customer Name</b></td>
  <td><b>Customer Email</b></td>
 </tr>

<?php
  while(odbc_fetch_row($queryexe)) {

   //Get the fields from a row of data in the table.
   $custnumber = odbc_result($queryexe, 1);
   $custname = odbc_result($queryexe, 2);
   $custemail = odbc_result($queryexe, 3);

   //Put the fields in an HTML table.
   print("<tr bgcolor=#ffffff>\n");
   print("<td>$custnumber</td>\n");
   print("<td>$custname</td>\n");
   print("<td>$custemail</td>\n");
   print("</tr>\n");     
  }
 ?>     

I still have a couple of questions, though.

When setting up the DNS, under the 'Server' tab, I
placed the name of the library holding the physical
file I accessed. I assume this lets me access all
files within that library.  However, when I add
another library in the 'Library List' textbox, I get
error messages that suggest the ODBC driver is not
looking at the library shown in the 'Library List'
textbox. Any ideas how to a library list defined in
the DNS?

When setting up the DNS, under the 'General' tab, I
clicked the 'Connection Options' button and selected
'Use iSeries Navigator default' as the default user
ID.  How do I code the odbc_connect function to use
the default user ID and password?

This is starting to be fun.
Thanks,
Kelly


                
_______________________________
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
http://promotions.yahoo.com/goldrush

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.