supernoob basic if() question

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
hurdy gurdy
Forum Commoner
Posts: 40
Joined: Mon Jun 09, 2003 8:19 pm

supernoob basic if() question

Post 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?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post 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;
hurdy gurdy
Forum Commoner
Posts: 40
Joined: Mon Jun 09, 2003 8:19 pm

Post by hurdy gurdy »

ah, but if I delete the if() statement, then the echo works...

any ideas as to why?
ilovetoast
Forum Contributor
Posts: 142
Joined: Thu Jan 15, 2004 7:34 pm

Post by ilovetoast »

$filetype = "image/jpeg");

unmatched )

I changed that, and it works fine for me.....
hurdy gurdy
Forum Commoner
Posts: 40
Joined: Mon Jun 09, 2003 8:19 pm

Post 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!
ilovetoast
Forum Contributor
Posts: 142
Joined: Thu Jan 15, 2004 7:34 pm

Post 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
hurdy gurdy
Forum Commoner
Posts: 40
Joined: Mon Jun 09, 2003 8:19 pm

Post by hurdy gurdy »

It was staring me in the face.... I feel so stupid

Thanks for the help!
Post Reply