Jump to content

Probably Pathetic Problem with an If statement


jasonmbrown

Recommended Posts

ok well im just starting to learn php and im having a little bit of trouble with one of my if statements its supposed to check if a filename ends in a valid picture format however if i use && or || i still get the same output. as if its not even checking the file extension. Did i make a mistake when getting the file extension?

 

<?php
$ofile = fopen ("imgs/gallery.xml", "w+");
fwrite($ofile,'<tiltviewergallery><photos>');
$handle= opendir("imgs");
   while (false !== ($file = readdir($handle))) {
$x = strlen($file);
while ($x > -1){
	if (substr($file,$x, 1) == '.') {
	$filext = substr($file,$x + 1);
	fwrite(fopen("debug.txt","w+"),substr($file,$x, 1));
	}
$x=$x - 1;
}
		if (strcasecmp($filext,"jpg" == 0) && strcasecmp($filext,"png" == 0) && strcasecmp($filext,"gif" == 0) && strcasecmp($filext,"bmp" == 0) && strcasecmp($filext,"jpeg" == 0) && strcasecmp($filext,"tif" == 0) && strcasecmp($filext,"tiff" == 0))
		{
fwrite($ofile,'
<photo imageurl="imgs/'.$file.'">
</photo>');
		}
}
fwrite($ofile,'</photos></tiltviewergallery>');
fclose($ofile);
?>

 

thanks before hand ;)

 

Welll now im an idiot sorry for bothering people.

 

It should have been

if (strcasecmp($filext,"jpg") == 0)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.