0

Hi

I have a php script which creates an xml file

    //Select the Database
    mysql_select_db("personeelsbestand",$db);

    $result = mysql_query("select * from XMLAfdeling", $db);  

    //Create SimpleXMLElement object
    $xml = new SimpleXMLElement('<xml/>');

    //Add each column value a node of the XML object
    while($row = mysql_fetch_assoc($result)) {
        echo $row['Afdelingnaam']."\n";
        $mydata = $xml->addChild('mydata');
        $mydata->addChild('AfdelingID',$row['AfdelingID']);
        $mydata->addChild('Afdelingnaam',$row['Afdelingnaam']);
        $mydata->addChild('VestigingID',$row['CampusID']);
        $mydata->addChild('Vestiging',$row['Campus']);
        $mydata->addChild('DepartementsID',$row['DepartemenstID']);
        $mydata->addChild('Departement',$row['departement']);        
    }

    mysql_close($db);
    //Create the XML file
    $fp = fopen("UltimoAfdeling.xml","wb");

    //Write the XML nodes
    var_dump(fwrite($fp,$xml->asXML()));

    //Close the database connection
    fclose($fp);

when I run the code in my browser on my localhost it works perfectly but when I try to run it in the windows command prompt as administrator with the next command
C:\xampp\php\php.exe C:\xampp\htdocs\test\UltimoAfdelingXML.php
I can print the result to the command prompt but the script won't make the xml file.

Anny hints?

1
Contributor
1
Reply
12
Views
1 Year
Discussion Span
Last Post by nevek
1

solved it, I just had to use the absolute path int fopen

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.