Hello dear friends my name is ivette and i need help with the following code, what am trying to do is opening a data base and search for a specific record which will be shown in a xml file but the problem i have is that my query works but when i try to generate the xml file i can't please help me
#!C:\perl\bin\perl.exe -w #I USE THE LIBRARY use DBI; #WHERE I CONNECT WITH THE DATA BASE my $biblioperl = 'driver=Microsoft Access Driver (*.mdb);dbq=C:\\bibl +io.mdb'; my $dbh = DBI->connect("dbi:ODBC:$biblioperl",",") or die "$DBI::errst +r\n"; #WHERE I COMPARED THE SELECTION AND IF IT IS IN THE TABLE THEN IT MUST + SHOW IT $qrystrg = $ENV{'QUERY_STRING'}; $qrystrg =~ tr/+/ /; $qrystrg =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; ($varcampo1, $varcampo2) = split(/&/,$qrystrg); ($parcampo1,$varvalor1) = split(/=/,$varcampo1); ($parcampo2,$varvalor2) = split(/=/,$varcampo2); #QUERY $consulta = "SELECT Authors.Author, Titles.Title, Titles.[Year Publish +ed], Publishers.[Company Name], Titles.ISBN, Titles.Description, Titl +es.Notes FROM (Publishers INNER JOIN Titles ON Publishers.PubID = Tit +les.PubID) INNER JOIN (Authors INNER JOIN [Title Author] ON Authors.A +u_ID = [Title Author].Au_ID) ON Titles.ISBN = [Title Author].ISBN WHE +RE (((Titles.[Year Published])=$varvalor1))"; + + $sth = $dbh->prepare($consulta); $rv = $sth->execute() or die $dbh->errstr; #print qq~ #~; #I USE A FILE HANDLER WHICH WILL ALLOW ME TO WRITE IN EVERYTIME I #DO THE QUERY open (FILEXML, " > biblio.XML"); print " FILEXML <Structures>"; #print "<?xml version="1.0" encoding="ISO-8859-1"?>"; while( @data = $sth->fetchrow_array() ) { # I GENERATE THE STRUCTURE OF THE XML FILE print FILEXML "<Book>"; print FILEXML "<Author>$data[0]</Author>"; print FILEXML "<Title>$data[1]</Title>"; print FILEXML "<Y_Publi>$data[2]</Y_Publi>"; print FILEXML "<C_Name>$data[3]</C_Name>"; print FILEXML "<ISBN>$data[4]</ISBN>"; print FILEXML "<Descrip>$data[5]</Descrip>"; print FILEXML "<Notes>$data[6]</Notes>"; print FILEXML "</Book>"; } print FILEXML "</Structures>"; $sth->finish(); close(FILEXML); #print "Content-type: text/html\n\n"; #print "Location: http:\\localhost\resultado.html\"; $dbh->disconnect || warn "\nFalló al desconectar.\nError: $DBI::errstr +\n"; exit;

In reply to perl script and xml by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.