PhpDig.net

Go Back   PhpDig.net > General Forums > Coding & Tutorials

Reply
 
Thread Tools
Old 03-06-2005, 09:42 PM   #1
retrodog
Green Mole
 
Join Date: Mar 2005
Posts: 1
Unhappy How to use form data to create XML???

I have a form that submits captions via textboxes to a php page that gets written to an child node in an XML file. I am using a while loop since there are up to 35 caption textboxes into which a user can input data. I have tried everything to try to get the data into the XML, namely by using a while loop to get the $caption$i=$_POST['caption$i'] value.

The XML is written correctly when I use $caption1 instead '$caption$i' below so I know the data is being passed to the next page correctly. When I use '$caption$i' only 1, 2, 3, etc gets written to the string. When I use "$caption$i", then $caption$i gets written. SOMEONE PLEASE HELP! HOW CAN I GET THIS DATA TO DISPLAY CORRECTLY?

$doc = new_xmldoc('1.0');
$root = $doc->add_root('gallery');
$root->set_attribute('galleryname',"");
$root->set_attribute('layout',"2");

$i=1;
while ($i<$count)
{
$image = $root->new_child('image',"images/$i.jpg");
$image->set_attribute('thumb',"images/thumb_$i.jpg");
$captiontext = $root->new_child('captiontext', '$caption$i');
$i++;
}

// set output filename
$filename= "../../Clients/$firstname$lastname/gallery.xml";


$fp = @fopen($filename,'w');
if(!$fp) {
die('Error cannot create XML file');
}
fwrite($fp,$doc->dumpmem());
fclose($fp);
?>
retrodog is offline   Reply With Quote
Old 03-15-2005, 08:45 AM   #2
Charter
Head Mole
 
Charter's Avatar
 
Join Date: May 2003
Posts: 2,539
Perhaps the problem lies in the assignment of $_POST['caption$i'] to $caption$i in your code. Use error_reporting(E_ALL); and see what shows onscreen, and maybe consider using $caption[$i] = $_POST['caption$i']; and $captiontext = $root->new_child('captiontext', '$caption[$i]'); instead.
__________________
Responses are offered on a voluntary if/as time is available basis, no guarantees. Double posting or bumping threads will not get your question answered any faster. No support via PM or email, responses not guaranteed. Thank you for your comprehension.
Charter is offline   Reply With Quote
Reply

Thread Tools

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating an XML from a form (no ASP) calvin182 Coding & Tutorials 1 11-18-2005 01:58 AM
Noob question about form data irrompible Coding & Tutorials 1 11-10-2005 10:00 PM
Re-indexing Data Base Fast ezytrak Troubleshooting 1 03-15-2005 09:01 AM
Request: Meta-Data ~ jeremiah Mod Requests 1 07-14-2004 07:55 PM
Searching data in MySQL database maheshg How-to Forum 3 03-24-2004 10:21 AM


All times are GMT -8. The time now is 02:57 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.