The Note You're Voting On
oscargodson at gmail dot com ¶ 16 years ago
To add to what others have said, you can't directly put a $_GET or $_POST value into a variable then into an attribute using SimpleXML. You must first convert it to an integer.
This will NOT work
<?php
$page_id = $_GET['id'];
echo $xml->page[$page_id]
?>
You will get something like:
Notice: Trying to get property of non-object in /Applications/MAMP/htdocs/mysite/index.php on line 10
However, this WILL work and is much simpler then using (string) or other methods.
<?php
$page_id = intval($_GET['id']);
echo $xml->page[$page_id]
?>