grax has asked for the wisdom of the Perl Monks concerning the following question:

I need help, using CGI, ODBC and Flash. I am trying to output the results from a CGI, which performs an SQL statement on an ODBC data source, in HTTP headers so that it can be used in a dynamic text box in a Flash file. I can get the results to appear when run from a DOS prompt, but cannot retrieve any details in a browser. Ideally, I would prefer each row of the query results to be in a separate header, but can you force a CGI to output a HTTP header? Please can you help?
#!usr/perl/bin use CGI; use DBI; $q = new CGI; $message_id = 0; $message_date = ""; $message_time = ""; $message_sender_name = ""; $message_to_name = ""; $error_message = "No Records Found...Please Select Again"; $department_type_local = $q->param(department_type); print "got to end of vars\n"; $dbh = DBI->connect("DBI:ODBC:messagestore", "anonymous", "password") +or die "Couldn't connect to database"; $query = $dbh->prepare("SELECT [message_table].message_id], [message_t +able].[message_date], [message_table].[message_time], [message_table] +.[message_sender_name], [message_table].[message_to_name], [message_t +able].[department_id] FROM message_table WHERE((([message_table].department_id]) = ?)); +"); $query->execute($department_type_local) or die "Couldn't execute state +ment"; open (flha, "message.html") or die "Can't open html doc.\n"; while (<flha>){ print; } close flha; open (messagelog, "messagelog.log") or die "Can't open temp log file.\ +n"; if ($query->rows == 0){ print $error_message; } else { while (@data = $query->fetchrow_array()){ $message_id = $data[0]; $message_date = $data[1]; $message_time = $data[2]; $message_sender_name = $data[3]; $message_to_name = $data[4]; } } close messagelog; $query->finish; $dbh->disconnect;

Edit: chipmunk 2001-05-02

Replies are listed 'Best First'.
Re: CGI help.
by Caillte (Friar) on May 02, 2001 at 14:53 UTC

    The most flexible way to create a HTTP header is via the Cgi.pm header() command. Look it up in the Cgi docs.

    $japh->{'Caillte'} = $me;

Re: CGI help.
by Beatnik (Parson) on May 02, 2001 at 15:50 UTC
    Perl::Flash is ofcourse always an option :)

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
Re: Help combining CGI, ODBC, and Flash
by cei (Monk) on May 02, 2001 at 22:23 UTC
    I'm guessing you're not using Generator here? (If you were, you could do the ODBC calls directly from within Flash...)

    With a straight Flash file, AFAIK, the best ways to get external variables into a movie are either from an external text file or passing them through the URL of the embed tag.

    If you want this to be dynamic, then the text file is out.

    So what I would do if I were in your shoes, is use the Perl to output the HTML page that holds the EMBED and OBJECT tags, and dynamically change the bit of your URL that could hold variables.

    Your EMBED will have something like src="myflashmovie.swf". You can easily change that to be src = "myflashmovie.swf?var1=foo&var2=bar", where the values "foo" and "bar" are substituted based on your ODBC select.

    Does that make any sense? I could go into more detail...