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?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.