CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: DBI:
I'm having trouble creating tables in mysql via cgi. Please help!

 



jerry000
New User

Jul 4, 2008, 8:15 PM

Post #1 of 2 (3850 views)
I'm having trouble creating tables in mysql via cgi. Please help! Can't Post

Hi,

I just started learning PERL and CGI scripting and am a complete newbie. So I sincerely apologize if my problem seems too simple for the guru's.

its been atleast two weeks that I've been trying to install a custom script on my server. The script named install_mysql.cgi - installs a set of mysql tables into the mysql server for the domain name.

The install_msql.cgi -> calls an admin-list.inc file which in turn calls the config file containing the info for mysql, such as dbname, user, password, and host and the iSubs.pm (module) file that aides in the building of the mysql tables.

The problem that I'm facing is rather strange: When I run the install_mysql.cgi from the browser, I get a message saying "The MySQL Database has been setup properly".

But when i refer to my server error log I get the following error messages:

[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::st execute failed: Table 'myfunlotto.lotto_pages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 188.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 220.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::st execute failed: Table 'myfunlotto.lotto_pages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 188.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 220.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Invalid default value for 'id' at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_advertisers' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Invalid default value for 'id' at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_books' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Invalid default value for 'id' at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Invalid default value for 'id' at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_members' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Invalid default value for 'id' at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_messages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_messages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_messages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Invalid default value for 'id' at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Invalid default value for 'id' at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_pages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_pages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_pages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_pages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_pages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Table 'myfunlotto.lotto_pages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Invalid default value for 'id' at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::db do failed: Invalid default value for 'id' at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 182.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::st execute failed: Table 'myfunlotto.lotto_pages' doesn't exist at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 188.
[Fri Jul 04 13:19:27 2008] [error] [client 68.84.40.48] [Fri Jul 4 13:19:27 2008] install_mysql.cgi: DBD::mysql::st fetchrow_hashref failed: fetch() without execute() at /var/www/vhosts/myfunlotto.com/httpdocs/lotto/data_files/iSubs.pm line 220.

---------------------------------------

iSubs.pm file:

sub OpenMySQL {
use DBI;
$dbh = DBI->connect("DBI:mysql:$mysql_db:$mysql_host",$mysql_u,$mysql_p) or die $DBI::errstr;
$mysqlopen = 1;
return; }

sub CloseMySQL {
$dbh->disconnect();
$mysqlclosed = 1;
return; }

sub DoMySQL {
if (!$mysqlopen) { &OpenMySQL; }
$dbh->do("$_[0]");
return; }

sub PrepareMySQL {
if (!$mysqlopen) { &OpenMySQL; }
$result = $dbh->prepare("$_[0]");
$result->execute();
return; }

I spent a lot of time researching on the web and the books but I just could not find a solution.

I would really appreciate your expert advice and help on how to resolve this error.

Thanks a lot guys!

Best Wishes,
genX_000!

Here is the install_mysql.cgi code:

There is an invalid value for 'id' error repeated in the error logs so I'm thinking this is becuase install_mysql.cgi inserts interger values into the table in quotes. But i tried creating a test table from ssh terminal and inserted interger values into test table in quotes and it worked fine. So I'm not sure what to do. Please guide me.


Code
 
#!/usr/bin/perl

use CGI::Carp qw(fatalsToBrowser);
require "admin-list.inc";

$section = "Setting Up the MySQL Database ...";
&PrintHead;
&DoMySQL("CREATE TABLE $advtable (id int(10) DEFAULT '' NOT NULL auto_increment, userid varchar(35) DEFAULT '' NOT NULL , password varchar(35) DEFAULT '' NOT NULL , company varchar(75) , url varchar(255) , email varchar(75) DEFAULT '' NOT NULL , fullname varchar(75) DEFAULT '' NOT NULL , orders int(10) DEFAULT '0' NOT NULL , totalspent float DEFAULT '0' NOT NULL , extra1 varchar(75) , extra2 varchar(75) , extra3 varchar(75) , PRIMARY KEY (id), KEY custid (id))");
&DoMySQL("INSERT INTO $advtable (id,userid,password,company,url,email,fullname,orders,totalspent,extra1,extra2,extra3) VALUES('1','admin','$adminpassword','$site_name','$clickthru_url','$admin_email','$admin_name','0','0','','','')");
&DoMySQL("CREATE TABLE $bookstable (id int(24) DEFAULT '' NOT NULL auto_increment, userid varchar(35) DEFAULT '' NOT NULL , refclicks int(24) DEFAULT '0' NOT NULL , referrals int(24) DEFAULT '0' NOT NULL , tickets_played int(24) DEFAULT '0' NOT NULL , tickets_avail int(24) DEFAULT '0' NOT NULL , tickets_won int(24) DEFAULT '0' NOT NULL , PRIMARY KEY (id), UNIQUE userid (userid))");
&DoMySQL("INSERT INTO $bookstable (id,userid,refclicks,referrals,tickets_played,tickets_avail,tickets_won) VALUES('1','admin','0','0','0','100','0')");
&DoMySQL("CREATE TABLE $drawtable (id int(10) DEFAULT '' NOT NULL auto_increment, win_number int(3) DEFAULT '0' NOT NULL , win_date varchar(50) DEFAULT '' NOT NULL , win_time varchar(50) DEFAULT '' NOT NULL , win_ip varchar(50) DEFAULT '' NOT NULL , winners int(10) DEFAULT '0' NOT NULL , PRIMARY KEY (id))");
&DoMySQL("CREATE TABLE $memtable (id int(9) DEFAULT '' NOT NULL auto_increment, userid varchar(35) DEFAULT '' NOT NULL , password varchar(35) DEFAULT '' NOT NULL , first varchar(35) DEFAULT '' NOT NULL , last varchar(35) DEFAULT '' NOT NULL , email varchar(125) DEFAULT '' NOT NULL , city varchar(125) , state char(2) , zipcode varchar(125) , notes text , status varchar(75) DEFAULT '' NOT NULL , estatus varchar(75) DEFAULT '' NOT NULL , vcode varchar(128) , ipadd varchar(50) DEFAULT '' NOT NULL , referrer varchar(35) , PRIMARY KEY (id), UNIQUE userid (userid), KEY id (id))");
&DoMySQL("INSERT INTO $memtable (id,userid,password,first,last,email,city,state,zipcode,notes,status,estatus,vcode,ipadd,referrer) VALUES('1','admin','$admin_password','$admin_name','($site_name)','$admin_email','Your City','FL','33713',NULL,'ACTIVE','VERIFIED','','$ipadd','')");
&DoMySQL("CREATE TABLE $msgtable (id int(10) DEFAULT '' NOT NULL auto_increment, messageid varchar(50) DEFAULT '' NOT NULL , contents longtext DEFAULT '' NOT NULL , lastedited varchar(255) DEFAULT '' NOT NULL , description longtext , PRIMARY KEY (id), UNIQUE messageid (messageid), KEY id (id))");
&DoMySQL("INSERT INTO $msgtable (id,messageid,contents,lastedited,description) VALUES('1','Verify Email','Hi ~firstname~,\n\nIn order for you to start using your account you must\nclick on the email verification link included below.\n\nEmail Verification Link:\n~cgibin~/verify.cgi?~vcode~\n\n\nAdmin,\n~sitename~','','Email Verification Link Message')");
&DoMySQL("INSERT INTO $msgtable (id,messageid,contents,lastedited,description) VALUES('2','Password Resend','Hi ~firstname~,\n\nHere is your login information as requested by you or some\none at ~ipaddress~.\n\nUser ID: ~userid~\nPassword: ~password~\n\n\nAdmin,\n~sitename~','','Password Resend Email Message')");
&DoMySQL("INSERT INTO $msgtable (id,messageid,contents,lastedited,description) VALUES('3','Winner Notification','Congratulations ~firstname~, You have WON!!\r\n\r\nDetails and Prize Redeeming Instructions go here.\r\n','','This is the member winning ticket notification email. Here add the instructions on how to redeem the prize you are offering for winning.')");
&DoMySQL("CREATE TABLE $orderstable (id int(10) DEFAULT '' NOT NULL auto_increment, userid varchar(35) DEFAULT '' NOT NULL , linkid varchar(25) , linkurl text DEFAULT '' NOT NULL , linktype varchar(128) , linkxtra text , maxclicks int(10) DEFAULT '0' NOT NULL , status varchar(128) DEFAULT '' NOT NULL , datedone varchar(12) , clicks int(11) DEFAULT '0' NOT NULL , PRIMARY KEY (id))");
&DoMySQL("CREATE TABLE $htmtable (id int(10) DEFAULT '' NOT NULL auto_increment, pageid varchar(255) DEFAULT '' NOT NULL , contents longtext DEFAULT '' NOT NULL , lastedited varchar(255) DEFAULT '' NOT NULL , description varchar(255) , PRIMARY KEY (id), KEY id (id))");
&DoMySQL("INSERT INTO $htmtable (id,pageid,contents,lastedited,description) VALUES('1','Referral Banners Page','Banner Option #1:\r\nBanner #1 HTML Code:<p align=\"center\"><a href=\"~cgibin~/p.cgi?~userid~/index.html\" target=\"_blank\"><img src=\"/imgs/banner_001.gif\" border=\"0\"></a></p>','','Banners you want your members to use for promting your Lotto Site. Use (~cgibin~/p.cgi?~userid~/index.html) where you want the referral link displayed.')");
&DoMySQL("INSERT INTO $htmtable (id,pageid,contents,lastedited,description) VALUES('2','Banner Code', 'Add banner code here for the banner you want displayed when advertisers are not shown.', '', 'Default Banner Code for ALL your pages')");
&DoMySQL("INSERT INTO $htmtable (id,pageid,contents,lastedited,description) VALUES('3','Template Header', '<TABLE WIDTH=750 BORDER=0 CELLPADDING=0 CELLSPACING=0 align=&quot;center&quot;>\r\n <TR> \r\n <TD COLSPAN=2> <IMG SRC=&quot;http://www.myfunlotto.com/images/lotto_01.jpg&quot; WIDTH=141 HEIGHT=80 ALT=&quot;&quot;></TD>\r\n <TD COLSPAN=11 background=&quot;http://www.myfunlotto.com/images/lotto_02.jpg&quot;> \r\n <table width=&quot;90%&quot; border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;10&quot; align=&quot;center&quot;>\r\n <tr> \r\n <td><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;4&quot;><b><font color=&quot;#FFFFFF&quot;>www.myfunlotto.com<br>\r\n <font size=&quot;3&quot;>Just Play & Win!</font></font></b></font></td>\r\n </tr>\r\n </table>\r\n </TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=1 HEIGHT=80 ALT=&quot;&quot;></TD>\r\n </TR>\r\n <TR> \r\n <TD COLSPAN=4> <a href=&quot;http://www.myfunlotto.com&quot;><IMG SRC=&quot;http://www.myfunlotto.com/images/lotto_03.jpg&quot; WIDTH=170 HEIGHT=29 ALT=&quot;&quot; border=&quot;0&quot;></a></TD>\r\n <TD COLSPAN=3> <a href=&quot;http://www.myfunlotto.com/cgi-bin/signup.cgi&quot;><IMG SRC=&quot;http://www.myfunlotto.com/images/lotto_04.jpg&quot; WIDTH=131 HEIGHT=29 ALT=&quot;&quot; border=&quot;0&quot;></a></TD>\r\n <TD> <a href=&quot;http://www.myfunlotto.com/login.html&quot;><IMG SRC=&quot;http://www.myfunlotto.com/images/lotto_05.jpg&quot; WIDTH=103 HEIGHT=29 ALT=&quot;&quot; border=&quot;0&quot;></a></TD>\r\n <TD COLSPAN=3> <a href=&quot;http://www.myfunlotto.com/cgi-bin/advert/signup.cgi&quot;><IMG SRC=&quot;http://www.myfunlotto.com/images/lotto_06.jpg&quot; WIDTH=155 HEIGHT=29 ALT=&quot;&quot; border=&quot;0&quot;></a></TD>\r\n <TD COLSPAN=2> <a href=&quot;http://www.myfunlotto.com/advert/login.html&quot;><IMG SRC=&quot;http://www.myfunlotto.com/images/lotto_07.jpg&quot; WIDTH=191 HEIGHT=29 ALT=&quot;&quot; border=&quot;0&quot;></a></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=1 HEIGHT=29 ALT=&quot;&quot;></TD>\r\n </TR>\r\n <TR> \r\n <TD COLSPAN=13 align=&quot;left&quot; valign=&quot;top&quot;>', '', 'Top part of the HTML Coding for EVERY page made thru the script.')");
&DoMySQL("INSERT INTO $htmtable (id,pageid,contents,lastedited,description) VALUES('4','Template Footer', ' </TD><HTML>\r\n <HEAD>\r\n <TITLE>www.myfunlotto.com FREE LOTTO</TITLE>\r\n </HEAD>\r\n <BODY BGCOLOR=#FFFFFF LEFTMARGIN=0 TOPMARGIN=0 MARGINWIDTH=0 MARGINHEIGHT=0>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=1 HEIGHT=8 ALT=&quot;&quot;></TD>\r\n </TR>\r\n <TR> \r\n <TD colspan=&quot;13&quot; bgcolor=&quot;#000000&quot;>\r\n <div align=&quot;center&quot;><font face=&quot;Arial, Helvetica, sans-serif&quot; size=&quot;2&quot; color=&quot;#FFFFFF&quot;>Copyright \r\n www.myfunlotto.com 2004</font></div>\r\n </TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=1 HEIGHT=37 ALT=&quot;&quot;></TD>\r\n </TR>\r\n <TR> \r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=87 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=54 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=8 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=21 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=5 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=73 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=53 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=103 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=44 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=11 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=100 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=20 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD> <IMG SRC=&quot;http://www.myfunlotto.com/images/spacer.gif&quot; WIDTH=171 HEIGHT=1 ALT=&quot;&quot;></TD>\r\n <TD></TD>\r\n </TR>\r\n</TABLE></body></html>', '', 'Bottom part of the HTML Coding for EVERY page made thru the script.')");
&DoMySQL("INSERT INTO $htmtable (id,pageid,contents,lastedited,description) VALUES('5','Members Main Page','Welcome to the ~sitename~ Members Section! Put information about the prizes you are offering here.','','HTML Coding you want displayed on the members section main page.')");
&DoMySQL("INSERT INTO $htmtable (id,pageid,contents,lastedited,description) VALUES('6','Advertisers Main Page','Welcome to the ~sitename~ Advertisers Section!','','HTML Coding you want displayed on the advertisers section main page.')");
&DoMySQL("CREATE TABLE $ticketstable (id int(10) DEFAULT '' NOT NULL auto_increment, userid varchar(35) DEFAULT '' NOT NULL , a int(1) DEFAULT '0' NOT NULL , b int(1) DEFAULT '0' NOT NULL , c int(1) DEFAULT '0' NOT NULL , status varchar(28) DEFAULT '' NOT NULL , ipadd varchar(50) DEFAULT '' NOT NULL , dateplayed varchar(50) DEFAULT '' NOT NULL , extra varchar(255) , PRIMARY KEY (id))");
&DoMySQL("CREATE TABLE $tracktable (id int(10) DEFAULT '' NOT NULL auto_increment, userid varchar(35) DEFAULT '' NOT NULL , ipadd varchar(50) DEFAULT '' NOT NULL , linkid varchar(25) DEFAULT '' NOT NULL , date varchar(12) DEFAULT '' NOT NULL , time varchar(15) DEFAULT '' NOT NULL , PRIMARY KEY (id))");
print "<p> &nbsp;&nbsp; </p>\n";
print "<p><b>The MySQL Database has been setup properly</b></p>\n";
print "<p> &nbsp;&nbsp; </p>\n";
&PrintFoot;
exit;

The table's has been defines as follows in iSub.pm:

$memtable = "$prefix"."_members";
$msgtable = "$prefix"."_messages";
$htmtable = "$prefix"."_pages";
$ticketstable = "$prefix"."_tickets";
$bookstable = "$prefix"."_books";
$advtable = "$prefix"."_advertisers";
$tracktable = "$prefix"."_tracking";
$orderstable = "$prefix"."_orders";
$ticketstable = "$prefix"."_tickets";
$drawtable = "$prefix"."_drawings";



pengo
New User

Jul 10, 2008, 6:52 AM

Post #2 of 2 (3609 views)
Re: [jerry000] I'm having trouble creating tables in mysql via cgi. Please help! [In reply to] Can't Post

in the following subs place some || die conditions to get the sql error msg which you can not see on the browser because there are being ignored by perl.


Code
sub DoMySQL { 
if (!$mysqlopen) { &OpenMySQL; }
$dbh->do("$_[0]") || die "DoMySQL failed with sql error: ".$dbh->errstr."\n";
return; }

sub PrepareMySQL {
if (!$mysqlopen) { &OpenMySQL; }
$result = $dbh->prepare("$_[0]");
$result->execute() || die "PrepareMySQL failed with sql error: ".$dbh->errstr."\n";
return; }


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives