craigmarksmith has asked for the wisdom of the Perl Monks concerning the following question:
I have a simple PERL script thats called using a HTML form.
All it does is takes a string then opens a file and writes XML content to it.
Here is a small code sample:
use DBI; use HTML::Entities (); use IO; use XML::Writer; use Date::Language; use CGI; my $query = new CGI; print $query->header(); $atom_id = $query->param('atom_id'); my $lang = Date::Language->new('English'); # Set up DB parameters my $dbh = DBI->connect ("DBI:mysql:database=sbsContacts;host=localhost +", "root", "cobweb123", {RaiseError => 1, PrintError => 0}); # Outer loop - get all scheme IDs where flag is set $sbs_query = $dbh->prepare("SELECT * FROM sbs_contacts WHERE for_sbs = + 'Y' AND atom_id = ?"); $sbs_query->execute($atom_id); # Create the file where all the contact XML will be printed my $output = new IO::File(">$atom_id.xml"); #PROBLEM HERE! my $writer = new XML::Writer(OUTPUT => $output, DATA_MODE => 'true', D +ATA_INDENT => 2);
In the browser the code fails on the last line but its ok on command line. Can anyone help.
Craig
20040705 Edit by Corion: Put code in code tags
20040706 Edit by castaway: Changed title from 'XML::WRITER'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XML::Writer writes file from the command line but not via a CGI
by Happy-the-monk (Canon) on Jul 05, 2004 at 09:08 UTC | |
by craigmarksmith (Novice) on Jul 05, 2004 at 10:00 UTC |