tags:

views:

235

answers:

2

Hi All, i have a form on a php5 page. All i trying to do is parse out some xml entered into that form (COMMAND) using simplexml_load_string here is the test code:

//BEGIN ' . $Input .XML;

 $xml = simplexml_load_string($Data);
 var_dump($xml); 
}
    else
}
    echo 'WTF!'
}

?>

Test ' //END

this is the error i am receiving: Parse error: syntax error, unexpected $end in /var/www/cgi/index.php on line 24

i think it has something to do with my weak attempt at concatenation. Any help would be much appreciated! Thanks -Phil

+1  A: 

You have a closing brace where you want an opening brace:

}
    else
}   // <- BAD!
    echo 'WTF!'
}

You want:

}
    else
{   // <- GOOD!
    echo 'WTF!'
}

This is a personal choice, but I'd recommend following the PEAR standard for PHP coding. Your code would appear as:

if (...) {
} else {
}

Makes it a lot easier to catch those evil braces!

hobodave
A: 

In addition to what hobodave wrote you are missing a ; on your

echo 'WTF!';

line

Rob Booth
Thanks rob, but still no dice.
You'll need to supply more code then if you want better debugging. From what you showed us hobodave and I have pointed out the syntax errors. But we don't know if you have a problem in another place. Other than the syntax errors we've pointed out your supplied code looks good.
Rob Booth