Forum Moderators: coopster
I have written a script that reads Name and Email of the user from database and then I write all values in XML format onto an already existing file "list.xml".
list.xml contains this line already,
Code:
<?xml version="1.0" encoding="UTF-8"?>
here is what i have done so far
PHP Code:
global $fname;
$fname = "list".".xml";
global $fp;
DATABASE Connection etc to get names in $names array and emails in $email array
PHP Code:
if($fp = fopen($fname,"a")) {
fputs($fp,"<emailscript>\r\n");
fputs($fp,"<retunrrow>\r\n");
fputs($fp,"<fullname>" .$names[$i]. "</fullname>\r\n");
fputs($fp,"<fullemail>" .$emails[$i]. "</fullemail>\r\n");
fputs($fp,"<retunrrow>\r\n");
fputs($fp,"</emailscript>\r\n");
}
else die("SORRY");
//after loop is ended
fclose($fp);
First of all it is giving me error for fclose($fp);
Code:
Warning: fclose(): supplied argument is not a valid stream resource in /home/#*$!/public_html/xxx/write.php on line 78
if i comment this line that it doesnt do anything, it just shows a blank white page, when i check the list.xml file it has nothing written onto it as a result of loop.
I am not sure what's going wrong with this, can anybody help please?