Isn't this is a variable - just a string which changes with each new ad??

Not in this case: $guestbookreal just holds the path and name of the file in which the data of the ad are stored. So you have to read what is in that file, which can be done as follows:

my $content; open FILE, '<', $guestbookreal; # Open a filehandle FILE to $guestbook +real while (<FILE>) { chomp; # delete any EOL character(s) $content .= $_; # Add the next line to the previous parts }

Now $content has the data you need. Then you do:

$sth=$dbh->prepare($content); $sth->execute();

Before anyone notices: I left out all error checking! A real script would be full of or die 'xxxx' statements.

Now as to the basic script you were using. The author himself wrote:
While the free code found at my web site has not evolved much in recent years, the general programming practices and standards of CGI programs have. nms is an attempt by very active programmers in the Perl community to bring the quality of code for these types of programs up to date and eliminate some of the bad programming practices and bugs found in the existing Matt's Script Archive code. I would highly recommend downloading the nms versions if you wish to learn CGI programming. The code you find at Matt's Script Archive is not representative of how even I would code these days.
So do me a favour and go to http://nms-cgi.sourceforge.net/ and replace your script with a more modern and up-to-date version.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law


In reply to Re: Re: Re: Re: Re: Re: Re: Re: Re: Modifying Perl script to write to MySQL?? by CountZero
in thread Modifying Perl script to write to MySQL?? by bobafifi

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.