views:

41

answers:

2

I am writing a PHP page to convert an uploaded file to XML. I only want to convert the news file to XML. The only file that ever needs to be converted is news.htm. I have narrowed my problem down to this if statement. What is wrong with it?

$fileName = basename( $_FILES['uploaded']['name'] );

if( strcmp( $fileName, "news.htm") == 0 )
(
    //convertToXML();
)
A: 

Try:

$fileName = basename( stripslashes( $_FILES['uploaded']['name'] ) );
Adam Bard
No. I have printed it out and I know it doesnt include slashes.
Josh Curren
Just a note, PHP does some weird stuff with the super globals. Sometimes I've had to do stripslashes on POST and GET variables to get preg_replace to work as expected on them.
Alex JL
+5  A: 

Use curly braces around the body of the if statement, instead of parentheses:

if( strcmp( $fileName, "news.htm") == 0 )
{
    //convertToXML();
}
Greg Hewgill
I cant believe I didnt notice that... I guess I need to get my eyes checked. Thanks!
Josh Curren