Connecting Tech Pros Worldwide Forums | Help | Site Map

fatal error on simplexml

anfetienne's Avatar
Needs Regular Fix
 
Join Date: Feb 2009
Location: UK
Posts: 356
#1: Jul 8 '09
hi, ive got a simplexml code to create xml files it worked before and now when i go to test it i get this error message "Fatal error: Call to undefined function: simplexml_load_string() in /home/theau10/public_html/resources/xmlcreator.php on line 17"

i've not changed any of my code but for some reason it comes with an error

Expand|Select|Wrap|Line Numbers
  1. <?
  2. session_start();
  3. if(!$_SESSION['myusername']){
  4. header("location:index.php");
  5. }
  6. ?>
  7. <?php error_reporting(E_ALL);
  8.  
  9. $returnURL = $_POST['returnURL'];
  10. $random_digit = $_POST['random_digit'];
  11. $xmlFiles = array();
  12.  
  13. if(isset($_POST['create_xml'])){
  14.  
  15. // Create the object (with header)
  16. $xmltext = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<images></images>";
  17. $xmlobj = simplexml_load_string($xmltext);
  18.  
  19.  
  20. foreach ($_POST['picT'] as $key => $value)
  21. {
  22.  
  23.     // Do something with your xml object
  24.     $child = $xmlobj->addChild("pics");
  25.     $child->addChild("image", $_POST['imageT'][$key]);
  26.     $child->addChild("thumbnail", $_POST['thumbnailT'][$key]);
  27.     $child->addChild("caption", $_POST['captionT'][$key]);
  28.  
  29. }
  30.  
  31.  
  32.  
  33.         $path_dir = "upload/$random_digit/";
  34.  
  35.         $path_dir .=   "images.xml";
  36.  
  37. /* Data in Variables ready to be written to an XML file */
  38.  
  39. $fp = fopen($path_dir,'w');
  40.  
  41.             $write = fwrite($fp,$xmlobj->asXML());
  42. }
  43. ?> 
  44.  
  45. <script language="JavaScript">
  46. <!--
  47. window.location="<? print $returnURL?>";
  48. //-->
  49. </SCRIPT>
  50.  

Dormilich's Avatar
Moderator
 
Join Date: Aug 2008
Location: Leipzig, Germany
Posts: 3,648
#2: Jul 8 '09

re: fatal error on simplexml


there are only three things I found.

either you're using PHP 4 or you're using Gentoo Linux (and didn't read the SimpleXML installation notes) or you compiled PHP explicitly without SimpleXML support.

"you" may also refer to the server admin
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,748
#3: Jul 8 '09

re: fatal error on simplexml


Yea, there appear to be very few reasons why simplexml wouldn't work, the most likely being that you are using PHP4 or earlier.
Reply