Wow! Thanks Rhino.

Yes, I already have http://www.usedflutes.com 
running on MySQL (the INSERT statements I just
post manually using phpMyAdmin and they load fine
that way).  However, I'd like to bypass the "copy
& paste" step for entering ads and if possible,
have them go/execute directly into mysql instead
by modifying the current html send of the script.



Thanks again

-Bob

--- Rhino <[EMAIL PROTECTED]> wrote:
> Bob,
> 
> I assume that you want to put the data from
> your Insert statement into a
> MySQL table, as opposed to inserting the text
> of your Insert statement into
> a table.
> 
> If I am right, then you'll need to do a few
> things:
> a) Create a database using the Create Database
> statement.
> b) Define a table that has the appropriate
> columns and datatypes. You
> already know what your columns need to be -
> Title, Email, City, etc. - but
> you need to choose an appropriate datatype and
> size for each of these
> columns. Use the Create Table statement to
> create the empty table.
> c) Write the Perl code to insert your data into
> the table. I'm not at all
> clear on how you propose to get the data. I'm
> guessing that you will present
> your users with an HTML input form and let them
> fill in each of the values
> for the row that you will create. If that is
> the case, your Perl code will
> have to display a form with input fields and
> those fields will have to be
> big enough for the largest value that you will
> put in the column. For
> example, if the CITY can never be more than 20
> characters long, you'll need
> your input field to be 20 characters long as
> well. Your Perl code should
> also validate the user's input. For example, if
> someone leaves the CITY
> blank or puts a phone number in that field,
> your code should detect that and
> display an error message to the user telling
> them what's wrong and asking
> them to try again. When the data is all valid,
> you need to insert the data
> into the table.
> 
> I haven't done very much Perl and what I did do
> was 5 years ago. However,
> this short example should get you going in the
> right direction. It assumes
> that a table already exists and has this
> definition:
> create table mytab
> (id smallint not null,
>  name char(10) not null,
>  primary key(id))
> 
>
----------------------------------------------------------------------------
> --------------------------------
> #!/usr/local/bin/perl
> 
> ###
> # This example demonstrates:
> # - making a connection
> # - setting the DBI debug level
> # - inserting a row of data
> # - disconnecting
> ###
> 
>  use DBI;
>  use DBD::DB2::Constants;
> 
>  $DBI::dbi_debug=3; # increase the debug output
> 
> # Attempt to connect to the database.
>  $dbh =
> DBI->connect("dbi:DB2:sample",logonID,passwd,
>    {RaiseError=>0,AutoCommit=>0});
> 
> # Commit so that rows can be added.
>  $dbh->commit();
> 
> # Populate the table.
>  $insert = "insert into mytab values
>     (1000, 'Fred'),
>     (2000, 'Barney')";
>  $sqlerrd3 = $dbh->do($insert);
>  print "Inserted ", $sqlerrd3, " rows\n";
> 
> # Display the table contents.
>  &display;
> 
> # Commit.
>     $dbh->commit();
> 
> # Reset the connection i.e. disconnect.
>     $dbh->disconnect();
> 
>  exit;
> 
> sub display {
> # Specify the info we want.
>     $stmt1 = "select id, name
>    from mytab
>    order by id";
> 
> # Prepare the statement.
>  $sth = $dbh->prepare($stmt1);
> 
> # Execute the statement.
>  $sth->execute();
> 
> # Loop through the result set, parsing each
> value into its own field.
>  while ( ( $id, $name ) = $sth->fetchrow() ) {
>   print "  ID: $id\tName: $name\n";
>   }
> 
> # Close the result set to free up resources.
>  $sth->finish();
> }
> 
>
----------------------------------------------------------------------------
> --------------------------------
> 
> Rhino
> 
> 
> ----- Original Message ----- 
> From: "Bob Afifi" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, February 13, 2004 8:00 PM
> Subject: Modifying Perl script to write to
> MySQL?
> 
> 
> > The Perl script I use is currently writing
> the
> > form results ($guestbookreal) to an html page
> >
>
(http://usedflutes.com/new_listings_publish.html):
> >
> > For example,
> >
> > INSERT INTO `mysql_db` (`Title`, `Email`,
> `City`,
> > `State`, `Country`, `URL`, `Date`,
> `Description`,
> > `rid`, `dt_create`, `publish` ) VALUES
> ('Test',
> > '[EMAIL PROTECTED]', 'Sebastopol', 'Ca',
> 'USA ',
> > 'http://bobafifi.com', 'Friday, February 13,
> 2004
> > ', 'Test', '', 'NOW()', 0)
> >
> > Can somebody please tell me how I need to
> change
> > the following code so that it will write the
> > results directly to MySQL instead??
> >
> > $guestbookreal =
> >
>
"/home/flute/usedflutes-www/new_listings_publish.html";
> >
> > Many thanks in advance,
> >
> > -Bob
> >
> >
> >
> >
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Finance: Get your refund fast by
> filing online.
> > http://taxes.yahoo.com/filing.html
> >
> > -- 
> > MySQL General Mailing List
> > For list archives:
> http://lists.mysql.com/mysql
> > To unsubscribe:   
>
http://lists.mysql.com/[EMAIL PROTECTED]
> >
> 


__________________________________
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online.
http://taxes.yahoo.com/filing.html

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to