in reply to Re: Re: Modifying Perl script to write to MySQL??
in thread Modifying Perl script to write to MySQL??

I think you have inserted the code I proposed too early. At that place in the script the SQL-statement is not yet written and moreover $guestbookreal just holds the name of the file where the SQL-statement will end up.

So you will have to retrieve the contents of that file (you can do that between the

close (GUEST); $dbh->disconnect;

statements and then plug it into a dbh->prepare statement there. You can then execute the SQL and put the data in your database.

Why Matt goes through so many hoops to do something which is rather easy to do, no-one at Perlmonks has ever been able to understand.

CountZero

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

Replies are listed 'Best First'.
Re: Re: Re: Re: Modifying Perl script to write to MySQL??
by bobafifi (Beadle) on Feb 15, 2004 at 23:25 UTC
    Hi CountZero,

    > moreover $guestbookreal just holds the name of the file where the SQL-statement will end up.

    But isn't that where the finished INSERT string/statement outputs to??
    $guestbookreal = "/home/flute/usedflutes-www/new_listings_publish.html +";
    http://usedflutes.com/new_listings_publish.html

    sorry, I'm somehow not getting the picture...

    Thanks again for your help CountZero,

    -Bob
Re: Re: Re: Re: Modifying Perl script to write to MySQL??
by bobafifi (Beadle) on Feb 16, 2004 at 00:50 UTC
    (cont.)

    Perhaps what I'm asking is if there is a way to execute the output string going to/thru $guestbookreal to MySQL "on-the-fly?"

    $guestbookreal=>mysql??

      $guestbookreal just holds the path and name of the file where your script will store the SQL-string you need to execute later: it does not hold this SQL-string itself directly.

      So what you need to do is to open this file and read it, put its contents in a scalar variable and execute that.

      I know, I know, it seems awfully convoluted and difficult and there is for sure a much more easy other solution available, but that would involve a major rewrite of your script. Then again, any rewrite of one of Matt's script is probably a "good thing™".

      CountZero

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

        I guess what I'm not getting a clear picture of maybe described like this:

        If the current output to the HTML page from $guestbookreal = "/home/flute/usedflutes-www/new_listings_publish.html"; (http://www.usedflutes.com/new_listings_publish.html is producing a string that I can literally copy & paste, drop into a GUI, and hit "GO" adds a new record to MySQL without any problem, then isn't there a syntax equivalent for that move - or is that not possible??

        Thanks once again for your help (and patience with me!) with this CountZero,

        -Bob