Current location: Hot Scripts Forums » Programming Languages » PHP » XML PHP MYSQL- Writing to a xml file


XML PHP MYSQL- Writing to a xml file

Reply
  #1 (permalink)  
Old 03-31-09, 11:57 PM
mackem mackem is offline
New Member
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
XML PHP MYSQL- Writing to a xml file

Hi, followed the excellent thread started by Punky79 on 03-08-08, 05:25 AM.

I want to do the same thing, using the same code by the look of it (from kirupa.com).

I want to save the xml to my server, not locally. Can't get it to work.

Very inexperienced programmer, so please be gentle!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 04-04-09, 11:15 PM
mackem mackem is offline
New Member
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Here's the code I'm using to generate xml in a browser window.
What code do I need to save that to the server as an xml file I can then access?


<?php require_once('friends.php'); ?>

<?php

("Content-type: text/xml");


mysql_select_db($database_friends, $friends);
$query_Recordset1 = "SELECT email FROM member_info ORDER BY email DESC";
$Recordset1 = mysql_query($query_Recordset1, $friends) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<entries>\n";

for($x = 0 ; $x < mysql_num_rows($Recordset1) ; $x++){
$row = mysql_fetch_assoc($Recordset1);

$xml_output .= "\t<entry>\n";
$xml_output .= "\t\t<email>" . $row['email'] . "</email>\n";
$xml_output .= "\t</entry>\n";
}

$xml_output .= "</entries>";

echo $xml_output;

?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 04-05-09, 09:38 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
PHP Code:



function XMLHeader($in_header)
{
  global $fp;
  fwrite($fp,sprintf("%s",$in_header));
}

function XMLStartTag($in_tag)
{
  global $fp;
  fwrite($fp,sprintf("<%s>",$in_tag));
}

function XMLEncode($in_tag,$in_data)
{
  global $fp;
  fwrite($fp,sprintf("<%s>%s</%s>",$in_tag,sanitize(4,0,$in_data),$in_tag));
}

function XMLEndTag($in_tag)
{
  global $fp;
  fwrite($fp,sprintf("</%s>",$in_tag));
}


$fp = @fopen('xml.xml',"wb");
XMLHeader ('<?xml version="1.0" encoding="ISO-8859-1" ?>');
XMLStartTag('CARRIER');
XMLEncode('ID',$id);
XMLEncode('NAME',$name);
XMLEncode('WEBSITE',$website);
XMLEncode('AREAS',$area);
XMLEndTag('CARRIER');  
fflush($fp);
fclose($fp);
http://us3.php.net/manual/en/xml.examples.php
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 04-07-09, 09:55 PM
mackem mackem is offline
New Member
 
Join Date: Mar 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks Wirehopper.

Thinking about it afterwards, I don't need to save the file, I can just access the php file through flash, because that is generating the xml file for me!
Cheers
Mackem
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and MySQL ? rob2132 Hot Scripts Forum Questions, Suggestions and Feedback 4 08-29-08 03:22 AM
Hi & Myphpadmin getting started help php_guru_besar New Members & Introductions 4 03-20-06 12:06 AM
Need help with some php mysql TheTinkeringToad PHP 9 02-01-06 11:56 AM
Complex mysql sorting pb (Get cat_list from cids &pcids with 1 query, willing to pay) aqw PHP 1 06-23-05 08:02 PM
UPDATE: MySQL Auto Backup & Export v1.1 Beyonder General Advertisements 2 03-21-05 03:05 PM


All times are GMT -5. The time now is 04:33 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.