Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

PHP source

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PHP source

    Hi Jeff, Thanks for writing the 2nd PHP article. I'm a PHP newbie, so I have a few questions/comments about your article. 1. Are you sure PHP (ver 5) functions must be listed at the top of the source code? I see lots of examples in books that don't comply with this. 2. Should you HTML encode the variable $val? (Using something like htmlentities() or htmlspecialchars() to encode <>&'" safely). 3. Can you use the 4th parm in db2_connect() to override the default SQL naming option, and use a / instead? 4. You have the user password coded right in the PHP script. Is there a better way? At least make it base64 or use an include file or something a bit more secure? 5. Your DB2_fetch_assoc appears to use the field name alias, since they field names are so long. Is that the case? How does PHP react if the field name has a @ or # in it which is valid in DB2, but I would guess not valid in PHP. 6. Will you be writing an article on the Zend Framework at some point? If so, when? Thanks! Chris

  • #2
    PHP source

    Chris, Thanks for your questions. Here's the answers... 1. Per the PHP coding standards that I have found, "functions in the Global scope are strongly discouraged". With that said, I sometimes do it; especially in the case of samples for articles and one-time use stuff. Technically I can find nothing that says that you can't put functions where ever you want but from a readability standpoint it makes sense to keep them together. IMHO. 2. Yes, you probably should use something along those lines to handle special characters from the file data. 3. Yes, you can use the OPTIONS parm on the DB2_CONNECT to change to use the standard I5 naming convention (using '/' instead of "."). The default is to use the period. 4. I did code the user name and password into the script. I did this on purpose to give the readers a visual on what needed to be passed to the function. This is what I do in my production scripts. First, I use an table of user names that is used for logging into the system (not to the iSeries). In this table of user names, each user name is associated with a company or group. The company/group that each user is associated with has certain properties (e.g. database library, job description, company name, etc...) that are common to all the users on that company or group and are stored in a company/group database. One of these common properties is the user profile and password for the iSeries login. Yes, I carry the password in the file. I use a modified XOR encryption so no one can simply query the file and get the passwords. This way the users and passwords are not in the PHP scripts and I need only a very small number of iSeries user profiles to accomodate many web users. 5. Good question. I'll have to try it and find out. I haven't used special characters in table names in a long time so I haven't run across this. 6. I have some other articles in the works. Nothing on the Zend Framework...yet. :-) Take care, Jeff Olen email: jmo@olen-inc.com phone: 760.703.5149 web: www.olen-inc.com

    Comment


    • #3
      PHP source

      I have been programming in Mid-Range for over 30 years. I am not adverse to learning new things as long as they work. How difficult is it to load PHP and write a very simple application using an existing RPG single screen inquiry as a start. The display allows the input of a location and a date range and returns appropriate values to a busy screen. The current program only has 814 lines and most of that is SQL statements and calls to other programs to collect the date. The screen itself has 3 input fields and 80 output fields. I am mainly curious.

      Comment


      • #4
        PHP source

        As far as the installation of PHP goes, its very straight forward. The ZEND Core for i5/OS install also installs PHP. The links for the install documents can be found here. Regarding development time, the most accurate answer is that it depends. It depends on what tools you are using (e.g. HTML templates, Style sheets, etc...). Also, your knowledge of HTML will play a big role in the time it takes to develop a PHP version. Based on your description of the existing iSeries program, I'd say you might have a fair bit of development to do to convert the inquiry you describe. You would probably want to use the existing programs to collect the data as much as possible. With that in mind you could start with learning the technique I covered in Part III on how to call native iSeries programs from PHP. Good luck, Jeff Olen Olen Business Consulting, Inc. email: jmo@olen-inc.com phone: 760.703.5149 web: www.olen-inc.com

        Comment


        • #5
          PHP source

          I have received several requests for a clean version of the source code from "TechTip: Start Using PHP on the iSeries...Now" dated 8-10-2007. So here it is. Also, some of the other posts have made mention of using HTML template files. A good utility to assist with this is the Smarty Template Engine Jeff Olen Olen Business Consulting, Inc. email: jmo@olen-inc.com phone: 760.703.5149 web: www.olen-inc.com

          table_list.php

          Comment


          • #6
            PHP source

            I didn't explain correctly. The program is split up into 2 major parts. The first accepts a store number and date range that is usewd by the second part to collect data and then that data is sent back to the first part and displayed on the screen. I was hoping that someone who can barely spell HTML might be able to muddle this into a web enabled program.

            Comment

            Working...
            X