Topic: PHP version differences

I'm using some code that was given me and it worked great on my hand coded site;  but i have been upgrading to a cms (Drupal) and I had my hosting company upgrade the php version to 5.x.x from 4.x.x. 

I was wondering if someone would look at this code and tell me what if any changes need to be made for php 5.x.x?

 
      <tr>
        <th>PLAY</th>
        <th>Video
       </th>
    </tr>
</thead>
<tbody>
<?
$dir = @ dir('./sermons/highspeed');
while ($entry = $dir -> read()) {
    if ($entry != '.' && $entry != '..' && strtolower(substr($entry, -3)) == 'wmv') {
?>
    <tr>
        <td><a href="sermons/highspeed/<? echo $entry; ?>">PLAY</a></td>
        <td><? echo substr($entry, 0, (strlen($entry) - 4)); ?></td>
    </tr>
<?
        } // each wmv file
    } // each directory entry
$dir -> close();
?>
</tbody>

Thank you in advance!!!
____________________________________________________________________________________________________
                                          As for me and my house;  we will serve the *LORD*!

Re: PHP version differences

I don't see anything that jumps out to me but it's been a few years since I've thought about the 4 -> 5 upgrade. The biggest change was in how they handle classes, but very few things we're actually not backward compatible. PHP5 difference in how you handle methods and function by reference but you're not doing that here. Seems all you are doing is using the file system calls which did not change.

I dream with an XML intereface

Re: PHP version differences

Tank,  Thanx!!!  It must be something to do with the way that I'm trying to use it on A Drupal cms site (still in the learning process) that is giving me the problem!  I've already posted there concerning this issue as well!  Thank you for helping me to eliminate this one element of questions that I had concerning this and have a great week!!!
_____________________________________________________________________________________________________
                                                         To live is *CHRIST*;  to die is gain!

Re: PHP version differences

sure. if you are seeing an actual error go ahead and post it here and maybe that will help.

I'm prob guessing that the issue is here

$dir = @ dir('./sermons/highspeed');

If you remove the @ (which suppresses errors) it may help track down the issue. My guess is that since you are using Drupal it is running the file in a different directory. So the path './sermons/highspeed' is no longer valid. you just may need to change that path. just take out that @ and then step through the code trying different things trying to find out where it goes wrong.

Last edited by tank (2009-12-15 13:47:26)

I dream with an XML intereface

Re: PHP version differences

Tank, thanx!  I tried that with no such luck!  It shows the php code even though I have php filtering enabled in modules and the input php format on the page enabled!  Either way with the (@) or not I get the same problem! I guess that it doesn't help that I'm learning Drupal on top of this problem!  Thank you for your suggestions! I'll keep on keeping on until I figure it out! Thanks again!
_____________________________________________________________________________________________________
                                      As for me and my house;  we will serve the *LORD*!

Re: PHP version differences

Okay I have a parse error on my Drupal site!  I finally did get the php code to read and pull in a video file;  but I get a parse error which is Parse error: syntax error, unexpected ';' in /home/username/public_html/includes/common.inc(1685) : eval()'d code on line 5.  I'm not sure exactly what it means! 

Then I used another php code snippet and it will pull in my video file;  but when play is clicked it says it cannot find the page!  It should be launching an external windows media player.  How do I get it to open in an external window to launch wmp as I beleive that it is trying to pull one from the cms instead?

Any ideas?  Thanks in advance!!!
_____________________________________________________________________________________________________
                                                         To live is *CHRIST*; to die is gain!

Re: PHP version differences

Thanks to all who viewed this post! I figured it out!  It helps if you disable the whizzywigg first!  I still have a lot to learn as I have never used a Drupal cms or any kind of cms!  I still have to work on the look and feel of the site;  but I'm very much encouraged by what I've seen so far!  Thanks very much for your help and have a great *CHRIST*-mas!!!
_____________________________________________________________________________________________________
   Isa 9:6.....*HIS* name shall be called Wonderful, Counsellor, The mighty God, The everlasting Father, The Prince of Peace.