Hello,
I am trying to copy data from 2 .xml files kai store them to a third .xml file usinh php. I want the data to be stored only once. I am using the follwing code
The get_infos function code is the follwingCode:<?php /* _________________________________________________________________________ */ include( 'includes/application_top.php' ); include( 'protection.php' ); $dc='http://purl.org/dc/elements/1.1/'; $dct='http://purl.org/dc/terms/'; // -------------------------------------------------- $cid = $_SESSION['lesson']; $mtd=array(); $mtd=get_infos( $FILE_LIB_XML, $cid ); // set the page title $PAGE_TITLE = 'FILE: '.$mtd["dc:title"][0]; // save the title $_SESSION['title'] = $mtd['dc:title'][0]; $bShowExtraData = TRUE; $existing_courses = get_infos($FILE_ARCHIVE_XML, $cid); if ( !in_array( $_POST['cid'], $existing_courses )){ copy_course($FILE_LIB_XML, $FILE_ARCHIVE_XML, $FILE_USERS_XML, $cid ); } // set the left column template $content_column = 'usermenu.tpl.php'; include( $DIR_TEMPLATES.'main.tpl.php' ); ?>
The problem is that when i am trying to update the archive.xml file if the data don't exist i get the follwing warningCode:function get_infos($xmlFile, $cid) { $mtd=array(); $visited=array(); $child= get_lesson($xmlFile, $cid); if(!$child) die("Cannot find lesson ID==".$cid); //get elements of course $cnt = $child->childNodes; foreach( $cnt as $cn ) { if($cn->nodeType== XML_ELEMENT_NODE) { if( !in_array( $cn->tagName, $visited ) ) { $visited[] = $cn->tagName; list($prefix, $tagname) = explode( ':', $cn->tagName ); $datas = $child->getElementsByTagName($tagname); $mtd[$cn->tagName] = array(); foreach( $datas as $data ) { $mtd[$cn->tagName][] = $data->textContent; } } } } return $mtd; }
thought the file is being updated.Code:Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\thalis\includes\functions.php on line 95
Anyone knows what's wrong?
I am using php 5





Reply With Quote