php seems to lose some variables (LAMP -- 4.3.4)

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

php seems to lose some variables (LAMP -- 4.3.4)

Post by m3rajk »

same section of code works on enterprise linux running 4.3.1

this is the segment that showed what's happening from the version with some debugging that showed that $sm was being lost. it is showing up as an empty variable in the print out. it should be a 0 or 1

Code: Select all

# set the pics                                                                                                                              
  $main="main.$uid.jpg"; $tmain=$faup.$main; $t1="t1.$uid.jpg"; $tt1=$faup.$t1; $t2="t2.$uid.jpg";
  $tt2=$faup.$t2; $t3="t3.$uid.jpg"; $tt3=$faup.$t3; $t4="t4.$uid.jpg"; $tt4=$faup.$t4;
  $salute="salute.$uid.jpg"; $tsalute=$faup.$salute; $unoa='sitepics/uona.png';

  # set what's approved                                                                                                                       
  $sm=0; $s1=0;  $s2=0;  $s3=0;  $s4=0;  $ss=0;
  if($userinfo['mp']==$ok){ $sm=1; $bleh='got here'; } // should the main pic be shown?                                                       
  if($userinfo['t1p']==$ok){ $s1=1; } // should the 1st thumb be shown?                                                                       
  if($userinfo['t2p']==$ok){ $s2=1; } // should the 2nd thumb be shown?                                                                       
  if($userinfo['t3p']==$ok){ $s3=1; } // should the 3rd thumb be shown?                                                                       
  if($userinfo['t4p']==$ok){ $s4=1; } // should the 4th thumb be shown?                                                                       
  if($userinfo['sp']==$ok){ $ss=1; } // should the salute pic be shown?                                                                       

  # find the height and width, or set to logo                                                                                                 
  if(is_file($tmain)&&($sm)){ list($mw, $mh)=getimagesize($tmain); } # we have and want to show a main                                        
  else{ $tmain=$unoa; list($mw, $mh)=getimagesize($unoa); $sm=FALSE; } // use the default                                                     
  if(is_file($tt1)&&($s1)){ list($t1w, $t1h)=getimagesize($tt1); } # we have and want to show thumb 1                                         
  else{ $tt1=$unoa; list($t1w, $t1h)=getimagesize($unoa); $s1=FALSE; } // use the default                                                     
  if(is_file($tt2)&&($s2)){ list($t2w, $t2h)=getimagesize($tt2); } # we have and want to show thumb 2                                         
  else{ $tt2=$unoa; list($t2w, $t2h)=getimagesize($unoa); $s2=FALSE; } // use the default                                                     
  if(is_file($tt3)&&($s3)){ list($t3w, $t3h)=getimagesize($tt3); } # we have and want to show thumb 3                                         
  else{ $tt3=$unoa; list($t3w, $t3h)=getimagesize($unoa); $s3=FALSE; } // use the default                                                     
  if(is_file($tt4)&&($s4)){ list($t4w, $t4h)=getimagesize($tt4); } # we have and want to show thumb 4                                         
  else{ $tt4=$unoa; list($t4w, $t4h)=getimagesize($unoa); $s4=FALSE; } // use the default                                                     
  if(is_file($tsalute)&&($ss)){ list($sw, $sh)=getimagesize($tsalute); } # we have and want to show a salute                                  
  else{ $tsalute=$unoa; list($sw, $sh)=getimagesize($unoa); $ss=FALSE; } // use the default                                                   

  if(is_file($tmain)){ $ifm='there'; }else{ $ifm='not'; }
  if($sm){ $smc='yes'; }else{ $smc='no'; }
  $debug="<p>debug: <br />uid= $uid<br />un=$un<br />main={$userinfo['mp']}<br />one={$userinfo['t1p']}<br />two={$userinfo['t2p']}<br />three={$userinfo['t3p']}<br />four={$userinfo['t4p']}<br />salute={$userinfo['sp']}<br />main: $ifm<br />show main? $smc -- $sm<br />$bleh</p>";
here's an example print out... note that the $sm didnt come threough, yet it executed the check where it got set to true. this was on one where all but the "salute" pic exist. and all those that exist should be shown. none are showing.
debug:
uid= 32
un=uzaho
main=9
one=9
two=9
three=9
four=9
salute=9
main: there
show main? no --
got here
Last edited by m3rajk on Tue Dec 28, 2004 7:59 pm, edited 1 time in total.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

thanx in advance for your help
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

else{ $tmain=$unoa; list($mw, $mh)=getimagesize($unoa); $sm=FALSE; } // use the default


$sm=FALSE;


echoing it out will output nothing.

maybe $tmain is not a file(doesnt exist) and causing it to set $sm to false on your other server.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

if you'd like, i can list the dir with the files and show you it does exist. that's what's got me here.

the variable used to set the path for the file is set correctly. reset the variable twice. for some reason the file is not being found. the file's permissions are 644

does the webserver need to have write permissions?
rehfeld
Forum Regular
Posts: 741
Joined: Mon Oct 18, 2004 8:14 pm

Post by rehfeld »

no it doesnt need write permissions. i dont even think it needs read permissions.

i think your file is not in the location you think it is,
or you are running the script from a diff location casuing your relative file path to fail.


in your code,
echo getcwd();

this will show you what directory you are in when the script is executing,
and you should be able to see if your relative file path is correct.
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

interesting. it points to the symbolic link it should point to, but the symbolic link is funky. the link doesnt work, but the place it points to does work

removed the links. recreated them. works again.

thanx
Post Reply