> Hello Dan, Howdy, please respond to the list and not just me so everyone can help/learn.
> > Thanks for the come back. > > I decided to accept PayPal and StormPay. I would need to > collect the PayPal Email, StormPay Email, and the peoples > name for a form to the MySql Table Correct? > > Would this work? To Create Table. > > use CGI::Carp qw(fatalsToBrowser); > > # MySQL (Database) Information > $sql_db_name = "randomizer"; > $sql_user = "randomizer"; > $sql_pass = "biz123"; > $sql_hostname =""; > $sql_port =""; > > > &Db_Connect; Why two calls to &Db_Connect? Use my() variables to keep from shooting yourself in the foot. Use strict and warnings/-w switch. > $SQL = "CREATE TABLE randomizer ( > Name varchar(40), > PayPal varchar(40), > StormPay varchar(25), > )"; > &Go_SQL; Why not just use do() to simplitfy and check the return value? > > &Db_Connect; > $SQL = "INSERT INTO randomizer (Name,PayPay,StormPay) > VALUES ('admin','[EMAIL PROTECTED]','[EMAIL PROTECTED]'')"; > &Go_SQL; > > $sth->finish; > $dbh->disconnect; ^^^^ I didn't see this declared earlier, another reason to use strict and my and use module functions instead of your own function that just runs that one function basically. > print "Content-type: text/html\n\n"; > print "<font face=\"$def_font\" size=\"$def_fsize\">\n"; > print "<p align=\"center\"><font size=\"5\" face=\"Arial > Black\" color=\"$name_clr\">Randomizer</font></p>\n"; > print "<p align=\"center\"> </p>\n"; > print "<center>\n"; > print "<B>Successfully Setup The MySQL Database!</B><P>The How do you know it was successful you didn't check any return values? > table \"randomizer\" was created for you within your database > :)<HR ALIGN=\"LEFT\" WIDTH=\"70%\">"; print "<P>A Randomizer > account was also setup for admin, your login information > is...<p>Username: admin<br>Password: adminpass<p>"; print > "<b>Remove, Delete or Rename this file now, It's No Longer > Needed For The List To Run!</b>"; print "</center>\n"; exit; ^^^^ Exit at the end of the script is pointless and possibly bad, like in mod_perl env. How about somethgin like this: #!/usr/bin/perl -w use strict; use CGI qw(header); use DBI; print header(); my $dbh = DBI->connect(...) or die "connect failed $DBI::errstr"; my $rc = $dbh->do("CREATE TABLE ...") or die "create table failed $DBI::errstr"; die "0E0 error on table create" if $rc =~ m/^0E0$/; $dbh->disconnect(); print "Well I made it this far without dieing I must be ok!"; See how much more readable it is? Also in a year or so when you or somebody else comes along it's easy to figure out what's going on. > > If So, Then how do I call it to random place the PayPal, > StormPay addresses into the buttons. > There was my original idea: Select all address into a list and choose a random one. Or Get one address from a query that returns a random one out of all of them. #2 would be better on memory and speed too I would assume since the script only has to work with 1 piece of data insead of building a list then choosing from it. Either way, get the data and put it in your form. HTH DMuey > Thanks in Advance > Dan > > ----- Original Message ----- > From: "Dan Muey" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, August 27, 2003 10:25 AM > Subject: RE: Mysql Question. Can Someone Help > > > > > > Hello Fellow Members, > > Howdy > > > > > I am new to perl and Mysql. I want to set up a mysql table to take > > Email addresses, and randomly place them into a payment button from > > PayPal, and StormPay. > > > > Can anyone tell me how to write the script to setup the > MySql Table to > > do this. > > > > Sure, you need to be familiar with the DBI module first off. > > Create your table and a user to SELECT from it. > > Look at the examples in perldoc DBI for how to do a multiple > row SLEECT query. Get the query : SELECT Email from > PayPalAccounts into an array, say @PPEmail > > then grab one at random like so: > my $email = $PPEmail[rand @PPEmail]; > > print qq(<input type="hidden" name="Account" value="$email">\n); > > > HTH > > DMuey > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]