|
03-06-2005, 10:42 PM | #1 |
Green Mole
Join Date: Mar 2005
Posts: 1
|
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); ?> |
03-15-2005, 09:45 AM | #2 |
Head Mole
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. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Creating an XML from a form (no ASP) | calvin182 | Coding & Tutorials | 1 | 11-18-2005 02:58 AM |
Noob question about form data | irrompible | Coding & Tutorials | 1 | 11-10-2005 11:00 PM |
Re-indexing Data Base Fast | ezytrak | Troubleshooting | 1 | 03-15-2005 10:01 AM |
Request: Meta-Data ~ | jeremiah | Mod Requests | 1 | 07-14-2004 08:55 PM |
Searching data in MySQL database | maheshg | How-to Forum | 3 | 03-24-2004 11:21 AM |