old PHP code not working on newer Apache/PHP server

Hello,
I’m hosting a website for a friend and upgraded my Fedora Linux server recently. The new system doesn’t work with some of the older code from one of the websites. Basically the code is supposed to parse through a directory and generate .jpg names (Example: 123.jpg) from a list of files so that the name of the .jpg matches the name of the file. The output is only generating:

<img border=“0” src=“images/.jpg”

I believe the source code that’s supposed to generate the number to create the jpg name “123.jpg” is coming from this code:

<?php echo $p; ?>

My best guess at this point is this is some kind of depricated function that no longer works in the newer version of php? I was also able to replicate the exact same issue with this website on a virtual Linux Mint 15 system running newer softare.

Any help would be greatly appreciated! Thanks, Scott

If you went from php 4 to php 5, then its entirely possible that whatever generates that variable has either been removed from php or there’s an error that’s killing the script. Just turn on error reporting and that should uncover any warnings or notices.

Hi Richei, Thanks for the suggestion. I have now enabled error logging and this is the error it’s throwing:

“Notice: Undefined variable: p in /var/www/mikescheer.com/vgallery.php on line 74”

Not sure why this would work in php 5.26 but not in php 5.49 - the website’s code is exactly the same on both servers.

Any idea on why this variable would show up as “Undefined” on the newer server?

Thanks, Scott

One more thing Richei,
I didn’t mention before that php variable is actually generated by some javascript code at the top of the page. This code was originally generated from Macromedia’s DreamWeaver back in the day I believe - before Macromedia was purchased by Adobe. Here is the javascript:

function MM_findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

Thanks for taking a look! Scott

php is seeing an empty variable before its being used. Just default it on top of the script.

That js isn’t pulling $b, its finding something on the page, its most likely in a loop somewhere from a query.

Sponsor our Newsletter | Privacy Policy | Terms of Service