Hey,
I have a bit of PHP I wrote which utilizes XML22, a couple php scripts that make parsing/editing/searching xml files a lot easier. I am using an XML file in my drupal root dir. When I create a page (say, random.php) the script works fine. But when I use this code inside of a Drupal page I get this error
array_shift(): The argument should be an array in /home/leboff/public_html/blah/includes/common.inc(1813) : eval()'d code on line 64.
The problem is the search is creating a blank array instead of working and returning the proper array. The piece of script that produces the error can be condensed to this:
include('xml22.inc');
$doc = xml22_parse('XMLFile.xml');
function findnames(){
global $doc, $idnum;
$name1 = $_POST['name1'];
$query3 = array('tag' => '/NODE_LABEL/', 'attributes' => array('label' => "/$name1/"));
$result3 = xml22_get_by_regex($doc, $query3);
if($result3 == null){
print "its empty";
}
$pirate3 = array_shift($result3);
$dad = xml22_get_parent($doc, $pirate3);
$idnum = xml22_get_attribute($dad, "nodeID");
return $idnum;
}
findnames();
i know it may be sloppy, but this is actually my first venture into PHP. The doc variable works correctly, as does name1 and query. The result isn't returning the correct variable. Does this possibly have something to do with the way Drupal processes php?
Help is greatly appreciated.