Page 1 of 1

supernoob basic if() question

Posted: Mon Jan 26, 2004 5:23 pm
by hurdy gurdy
Howdy

I have this simple little if statement that is supposed to read the filetype of a file submitted by a form and if the value of $filetype is the same as "image/pjpeg" change the value to "image/jpeg". It doesn't work. I get no error message, in fact nothing dispays on the page. As far as I can tell (supernoob here, almost no programming experience) there shouldn't be anything wrong.

Well, heres the code (snipped, relevent stuff shown):

Code: Select all

<?php
	$filename = $_FILES['photo']['name'];
	$filetype = $_FILES['photo']['type'];

	echo $filetype;
	
	
	if ($filetype == "image/pjpeg")
		{
		$filetype = "image/jpeg");
		echo $filename.' is now a '.$filetype;
		}
		else
		{
		echo $filetype." is not a jpeg.";
		}
	
?>
The only issue I can possibly see is theat the filetype isn't returning "image/pjpeg".

Can someone tell me where I went wrong?

Posted: Mon Jan 26, 2004 6:16 pm
by Illusionist
If you said nothing is showing up on the page then nothing is being stored into $filetype else if it was then you would see the file type with

Code: Select all

echo $filetype;

Posted: Mon Jan 26, 2004 7:09 pm
by hurdy gurdy
ah, but if I delete the if() statement, then the echo works...

any ideas as to why?

Posted: Mon Jan 26, 2004 7:45 pm
by ilovetoast
$filetype = "image/jpeg");

unmatched )

I changed that, and it works fine for me.....

Posted: Mon Jan 26, 2004 9:16 pm
by hurdy gurdy
$filetype = "image/jpeg");

unmatched )

I changed that, and it works fine for me.....
I'm not quite sure what you mean, could you clarifyplease?

thanks!

Posted: Mon Jan 26, 2004 9:30 pm
by ilovetoast
Change

$filetype = "image/jpeg");

to

$filetype = "image/jpeg";

and the script works fine for me. The parenthesis(sp.?) on your line is unmatched.

peace

Posted: Mon Jan 26, 2004 10:46 pm
by hurdy gurdy
It was staring me in the face.... I feel so stupid

Thanks for the help!