By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,660 Members | 1,230 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,660 IT Pros & Developers. It's quick & easy.

CGI to MYSQL on IIS6 not working

100+
P: 109
Hello all. This script I have did work on linux/apache and my service provider has told me the cgi-handler has been properly set up. I am able to get hello world test to display to a web page. My problem comes in when I try to connect to a mysql DB on IIS 6. My script reads as follows:

Expand|Select|Wrap|Line Numbers
  1. use DBI qw(:sql_types);
  2.  
  3. $title = 'EnergyWise Device Test - Reading List';
  4. $start = 40;
  5.  
  6. print <<ENDSTART;
  7. Content-Type: text/html; charset=iso-8859-1
  8.  
  9. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  10. <html lang="en-US">
  11. <head>
  12. <title>$title</title>
  13. </head>
  14. <body>
  15. <h1 style="font-size:1.2em">$title</h1>
  16. ENDSTART
  17.  
  18. $dbName = "DBI:mysql:database";
  19. $dbUser = "myuserid";
  20. $dbPass = "mypass";
  21. $numrows = 5;
  22. $dbh = DBI->connect($dbName, $dbUser, $dbPass) || die "Die: $DBI::errstr\n";
  23.  
  24.     $sql = "select max(raw_id) from data";
  25.     $sth = $dbh->prepare($sql) || die "prepare: $sql: $DBI::errstr";
  26.     $result = $sth->execute() || print "execute: $sql: $DBI::errstr";
  27.     @record = $sth->fetchrow();
  28.     $maxid = @record[0];
  29.     $sth->finish();
  30.     print $maxid," rows found.  Last ", $numrows, " shown below:";
  31.     $minid = $maxid-$numrows;
  32.     $sql = "select * from data where raw_id > \"$minid\"";
  33.     $sth = $dbh->prepare($sql) || die "prepare: $sql: $DBI::errstr";
  34.     $result = $sth->execute() || print "execute: $sql: $DBI::errstr";
  35.     while (@results = $sth->fetchrow() ) {
  36.         print "<p>Row ";
  37.         print @results[0];
  38.         print ":<p>";
  39.         print show(@results[1]);
  40.         }
  41.     $sth->finish();
  42.     $dbh->disconnect();
  43. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
  44. $now = sprintf "%4d-%02d-%02dT%02d:%02dZ", 1900+$year,$mon+1,$mday,$hour,$min;
  45. print p('Processed '.$now."\n");
  46. print end_html;
  47.  
  48. sub show {
  49.     $_[0] = escapeHTML($_[0]);
  50.     $_[0] =~ s/\r\n/<br>/g;
  51.     $_[0] =~ s/\n/<br>/g;
  52.     return $_[0]; }
Logically to me the script should function. What I get in return from the web page is:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.
Dec 10 '09 #1

✓ answered by RonB

Here's an adjusted version, which still has room for improvment.
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use CGI qw(:standard);
  6. use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
  7. use DBI qw(:sql_types);
  8.  
  9. print header();
  10. warningsToBrowser(1);
  11.  
  12. my $dbName = "egwtest";
  13. my $dbHost = "10.30.125.80";
  14. my $dbUser = "************";
  15. my $dbPass = "************";
  16.  
  17. my $dbh = DBI->connect("DBI:mysql:$dbName:$dbHost", $dbUser, $dbPass,
  18.                        { RaiseError => 1 })
  19.                or die "Die: $DBI::errstr\n";
  20.  
  21. # Prepare the SQL statement
  22. my $sth= $dbh->prepare("SELECT VERSION()") or die $DBI::errstr;
  23. # Send the statement to the server
  24. $sth->execute();
  25.  
  26. my $numRows = $sth->rows; # This is not always accurate.
  27. print "Rows returned: $numRows\n";
  28.  
  29. while ( my @row = $sth->fetchrow_array )
  30. {
  31.     print "@row\n";
  32. }
  33.  
  34. $dbh->disconnect(); 

Share this Question
Share on Google+
17 Replies


Expert Mod 100+
P: 589
Add this line just above the use DBI statement.
Expand|Select|Wrap|Line Numbers
  1. use CGI::Carp qw(fatalsToBrowser);
Then test the script and post back with the exact error message.
Dec 10 '09 #2

100+
P: 109
Expand|Select|Wrap|Line Numbers
  1. syntax error at \cgi-bin\newtest.cgi line 13, near "$dbHost "
  2. syntax error at \cgi-bin\newtest.cgi line 18, near "DBI:"
  3. Execution of \cgi-bin\newtest.cgi aborted due to compilation errors.
For help, please send mail to this site's webmaster, giving this error message and the time and date of the error.

I dumbed down the script to only use a small section of code. The code I'm using reads:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl -w
  2. use CGI qw(:standard);
  3. use CGI::Carp qw(fatalsToBrowser);
  4. use DBI qw(:sql_types);
  5.  
  6. print <<ENDSTART;
  7. Content-Type: text/html
  8.  
  9. <html>
  10. ENDSTART
  11.  
  12. $dbName = "egwtest"
  13. $dbHost = "10.30.125.80";
  14. $dbUser = "************";
  15. $dbPass = "************";
  16. $numrows = 5;
  17.  
  18. $dbh = DBI->connect(DBI:mysql:database=$dbName:host=$dbHost,$dbUser,$dbPass) || die "Die: $DBI::errstr\n";
  19.  
  20. # Prepare the SQL statement
  21. my $sth= $dbh->prepare("SELECT VERSION()") or die $DBI::errstr;
  22. # Send the statement to the server
  23. $sth->execute();
  24. my $numRows = $sth->rows;
  25. print "Rows returned: $numRows\n";
  26. my @row;
  27. while ( @row = $sth->fetchrow_array )
  28. {
  29. print "@row\n";
  30. }
  31.  
  32. $dbh->disconnect();
Dec 10 '09 #3

100+
P: 109
I think it is the syntax of my connection string.

$dbh = DBI->connect(DBI:mysql:database="egwtest":host="10.30. 125.80",$dbUser,$dbPass) || die "Die: $DBI::errstr\n";
Dec 10 '09 #4

Expert Mod 100+
P: 589
That version also has compilation errors.

C:\TEMP>perl -c dbrewerton.pl
[Thu Dec 10 08:26:01 2009] dbrewerton.pl: Scalar found where operator expected at dbrewerton.pl line 13, near "$dbHost"
[Thu Dec 10 08:26:01 2009] dbrewerton.pl: (Missing semicolon on previous line?)
[Thu Dec 10 08:26:01 2009] dbrewerton.pl: Unquoted string "mysql" may clash with future reserved word at dbrewerton.pl line 18.
[Thu Dec 10 08:26:01 2009] dbrewerton.pl: Unquoted string "database" may clash with future reserved word at dbrewerton.pl line 18.

[Thu Dec 10 08:26:01 2009] dbrewerton.pl: Unquoted string "host" may clash with future reserved word at dbrewerton.pl line 18.
Status: 500
Content-type: text/html

<h1>Software error:</h1>
<pre>syntax error at dbrewerton.pl line 13, near &quot;$dbHost &quot;
syntax error at dbrewerton.pl line 18, near &quot;DBI:&quot;
dbrewerton.pl had compilation errors.
</pre>
<p>
For help, please send mail to this site's webmaster, giving this error message
and the time and date of the error.

</p>
[Thu Dec 10 08:26:01 2009] dbrewerton.pl: syntax error at dbrewerton.pl line 13, near "$dbHost "
[Thu Dec 10 08:26:01 2009] dbrewerton.pl: syntax error at dbrewerton.pl line 18, near "DBI:"
[Thu Dec 10 08:26:01 2009] dbrewerton.pl: dbrewerton.pl had compilation errors.
Take out the -w switch and add these to lins (pragmas).
Expand|Select|Wrap|Line Numbers
  1. use strict;
  2. use warnings;
Those pragmas should be in every Perl script you write. They will help point out lots of mistakes/errors that can be difficult to track down otherwise.
Dec 10 '09 #5

Expert Mod 100+
P: 589
Here's an adjusted version, which still has room for improvment.
Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl
  2.  
  3. use strict;
  4. use warnings;
  5. use CGI qw(:standard);
  6. use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
  7. use DBI qw(:sql_types);
  8.  
  9. print header();
  10. warningsToBrowser(1);
  11.  
  12. my $dbName = "egwtest";
  13. my $dbHost = "10.30.125.80";
  14. my $dbUser = "************";
  15. my $dbPass = "************";
  16.  
  17. my $dbh = DBI->connect("DBI:mysql:$dbName:$dbHost", $dbUser, $dbPass,
  18.                        { RaiseError => 1 })
  19.                or die "Die: $DBI::errstr\n";
  20.  
  21. # Prepare the SQL statement
  22. my $sth= $dbh->prepare("SELECT VERSION()") or die $DBI::errstr;
  23. # Send the statement to the server
  24. $sth->execute();
  25.  
  26. my $numRows = $sth->rows; # This is not always accurate.
  27. print "Rows returned: $numRows\n";
  28.  
  29. while ( my @row = $sth->fetchrow_array )
  30. {
  31.     print "@row\n";
  32. }
  33.  
  34. $dbh->disconnect(); 
Dec 10 '09 #6

100+
P: 109
Ok, now I tried using what you show above and bringing it into my existing list.cgi script but I got tons of errors about Global symbol "$title" requires explicit package name. Do my variables need to be preceeded by my to make this work? Here is the script I'm trying to use:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl 
  2. use strict; 
  3. use warnings; 
  4. use CGI qw(:standard); 
  5. use CGI::Carp qw(fatalsToBrowser warningsToBrowser); 
  6. use DBI qw(:sql_types); 
  7.  
  8. $title = Reading List';
  9. $start = 40;
  10.  
  11. print <<ENDSTART;
  12. Content-Type: text/html; charset=iso-8859-1
  13.  
  14. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  15. <html lang="en-US">
  16. <head>
  17. <title>$title</title>
  18. </head>
  19. <body>
  20. <h1 style="font-size:1.2em">$title</h1>
  21. ENDSTART
  22.  
  23. my $dbName = "egwtest"; 
  24. my $dbHost = "10.30.125.80"; 
  25. my $dbUser = "**********"; 
  26. my $dbPass = "********"; 
  27. my $numrows = 5;
  28. my $dbh = DBI->connect("DBI:mysql:$dbName:$dbHost", $dbUser, $dbPass, { RaiseError => 1 }) or die "Die: $DBI::errstr\n"; 
  29.  
  30.     $sql = "select max(raw_id) from ewise_raw_data_in";
  31.     $sth = $dbh->prepare($sql) || die "prepare: $sql: $DBI::errstr";
  32.     $result = $sth->execute() || print "execute: $sql: $DBI::errstr";
  33.     @record = $sth->fetchrow();
  34.     $maxid = @record[0];
  35.     $sth->finish();
  36.     print $maxid," rows found.  Last ", $numrows, " shown below:";
  37.     $minid = $maxid-$numrows;
  38.     $sql = "select * from ewise_raw_data_in where raw_id > \"$minid\"";
  39.     $sth = $dbh->prepare($sql) || die "prepare: $sql: $DBI::errstr";
  40.     $result = $sth->execute() || print "execute: $sql: $DBI::errstr";
  41.     while (@results = $sth->fetchrow() ) {
  42.         print "<p>Row ";
  43.         print @results[0];
  44.         print ":<p>";
  45.         print show(@results[1]);
  46.         }
  47.     $sth->finish();
  48.     $dbh->disconnect();
  49. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime(time);
  50. $now = sprintf "%4d-%02d-%02dT%02d:%02dZ", 1900+$year,$mon+1,$mday,$hour,$min;
  51. print p('Processed '.$now."\n");
  52. print end_html;
  53.  
  54. sub show {
  55.     $_[0] = escapeHTML($_[0]);
  56.     $_[0] =~ s/\r\n/<br>/g;
  57.     $_[0] =~ s/\n/<br>/g;
  58.     return $_[0]; }
Dec 10 '09 #7

Expert Mod 100+
P: 589
Yes, you need to declare your vars with the my keyword just like you did for the db vars.

Also, when posting code, please use the code tags, like I did. It will retain the code indentation and makes it easier for us to help you. If you don't know where the code tag button is located, click on the "Go Advanced" button.
Dec 10 '09 #8

100+
P: 109
That one is fixed, now the other one I'm having a heck of a time with is this one called reading.cgi which allows me to import data using CGI into the MySQL DB. I don't have any undeclared vars but it is giving me that misbehaved error. Take a look please...thank you for all your help thus far :)

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl 
  2. use strict; 
  3. use warnings; 
  4. use CGI qw(:standard); 
  5. use CGI::Carp qw(fatalsToBrowser warningsToBrowser); 
  6. use DBI qw(:sql_types); 
  7.  
  8. my $dbName = "egwtest"; 
  9. my $dbHost = "10.30.125.80"; 
  10. my $dbUser = "************"; 
  11. my $dbPass = "***********"; 
  12. my $dbh = DBI->connect("DBI:mysql:$dbName:$dbHost", $dbUser, $dbPass, { RaiseError => 1 }) or die "Die: $DBI::errstr\n";
  13. my @fields = param();
  14. my @values = param(my $variable);
  15. my @filehandles = upload(my $variable);
  16.  
  17.  
  18. if(param()) {
  19.   for $variable(@fields) {
  20.     for my $value(@values) {
  21.       if(@filehandles) {
  22.         }
  23.       else {
  24.         $value =~ s/ / /g;
  25.     if($value eq '') {
  26.       }
  27.     else {
  28.       my $sql = "INSERT INTO data (raw_id, raw_data_xml) VALUES (default,\"$value\")";
  29.       my $sth = $dbh->prepare($sql) || die "prepare: $sql: $DBI::errstr";
  30.       $sth->execute() || print "execute: $sql: $DBI::errstr";
  31.       $sth->fetchrow();
  32.       $sth->finish();
  33.       $dbh->disconnect();
  34.       print "12.3";    # content
  35.       }
  36.     }
  37.       }
  38.     }
  39.   }
  40. else {
  41.   print "empty";
  42.   }
  43. print "</html>";
  44.  
  45. sub show {
  46.     $_[0] = escapeHTML($_[0]);
  47.     $_[0] =~ s/\r\n/<br>/g;
  48.     $_[0] =~ s/\n/<br>/g;
  49.     return $_[0]; }
It returns this:

CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers.

If nothing is being sent, it should just say empty.
Dec 10 '09 #9

Expert Mod 100+
P: 589
You didn't print the html header.
Dec 10 '09 #10

100+
P: 109
I tried it with header printing but no luck... It returns the following error:

Expand|Select|Wrap|Line Numbers
  1. Software error:
  2. Can't find string terminator "ENDSTART" anywhere before EOF at \cgi-bin\reading.cgi line 11.
  3.  

Here's what I have now:

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl 
  2. use strict; 
  3. use warnings; 
  4. use CGI qw(:standard); 
  5. use CGI::Carp qw(fatalsToBrowser warningsToBrowser); 
  6. use DBI qw(:sql_types); 
  7.  
  8. my $title = Reading List'; 
  9. my $start = 40; 
  10.  
  11. print <<ENDSTART; 
  12. Content-Type: text/html; charset=iso-8859-1 
  13.  
  14. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
  15. <html lang="en-US"> 
  16. <head> 
  17. <title>$title</title> 
  18. </head> 
  19. <body> 
  20. <h1 style="font-size:1.2em">$title</h1> 
  21. ENDSTART 
  22.  
  23.  
  24. my $dbName = "egwtest"; 
  25. my $dbHost = "10.30.125.80"; 
  26. my $dbUser = "**********"; 
  27. my $dbPass = "**********"; 
  28. my $dbh = DBI->connect("DBI:mysql:$dbName:$dbHost", $dbUser, $dbPass, { RaiseError => 1 }) or die "Die: $DBI::errstr\n";
  29. my @fields = param();
  30. my @values = param(my $variable);
  31. my @filehandles = upload(my $variable);
  32.  
  33.  
  34. if(param()) {
  35.   for $variable(@fields) {
  36.     for my $value(@values) {
  37.       if(@filehandles) {
  38.         }
  39.       else {
  40.         $value =~ s/ / /g;
  41.     if($value eq '') {
  42.       }
  43.     else {
  44.       my $sql = "INSERT INTO ewise_raw_data_in (raw_id, raw_data_xml) VALUES (default,\"$value\")";
  45.       my $sth = $dbh->prepare($sql) || die "prepare: $sql: $DBI::errstr";
  46.       $sth->execute() || print "execute: $sql: $DBI::errstr";
  47.       $sth->fetchrow();
  48.       $sth->finish();
  49.       $dbh->disconnect();
  50.       print "12.3";    # content
  51.       }
  52.     }
  53.       }
  54.     }
  55.   }
  56. else {
  57.   print "empty";
  58.   }
  59. print "</html>";
  60.  
  61. sub show {
  62.     $_[0] = escapeHTML($_[0]);
  63.     $_[0] =~ s/\r\n/<br>/g;
  64.     $_[0] =~ s/\n/<br>/g;
  65.     return $_[0]; }
  66.  
Dec 10 '09 #11

Expert Mod 100+
P: 589
Your first problem is with this line; it's missing the opening quote
Expand|Select|Wrap|Line Numbers
  1. my $title = Reading List'; 
Your next problem is with the here document that prints the header. We could fix it, but since it's a bad way of doing that, I won't. You're already loading the CGI module, so use it.

I've fixed those 2 issues, but there are others that you'll need to look at.

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl 
  2. use strict; 
  3. use warnings; 
  4. use CGI qw(:standard); 
  5. use CGI::Carp qw(fatalsToBrowser warningsToBrowser); 
  6. use DBI qw(:sql_types); 
  7.  
  8. my $title = 'Reading List'; 
  9. my $start = 40; 
  10.  
  11. print header(), start_html($title),
  12.       h1({-style=>"font-size:1.2em"}, $title);
  13.  
  14.  
  15. my $dbName = "egwtest"; 
  16. my $dbHost = "10.30.125.80"; 
  17. my $dbUser = "**********"; 
  18. my $dbPass = "**********"; 
  19. my $dbh = DBI->connect("DBI:mysql:$dbName:$dbHost", $dbUser, $dbPass, { RaiseError => 1 }) or die "Die: $DBI::errstr\n";
  20. my @fields = param();
  21. my @values = param(my $variable);
  22. my @filehandles = upload(my $variable);
  23.  
  24.  
  25. if(param()) {
  26.   for $variable(@fields) {
  27.     for my $value(@values) {
  28.       if(@filehandles) {
  29.         }
  30.       else {
  31.         $value =~ s/ / /g;
  32.     if($value eq '') {
  33.       }
  34.     else {
  35.       my $sql = "INSERT INTO ewise_raw_data_in (raw_id, raw_data_xml) VALUES (default,\"$value\")";
  36.       my $sth = $dbh->prepare($sql) || die "prepare: $sql: $DBI::errstr";
  37.       $sth->execute() || print "execute: $sql: $DBI::errstr";
  38.       $sth->fetchrow();
  39.       $sth->finish();
  40.       $dbh->disconnect();
  41.       print "12.3";    # content
  42.       }
  43.     }
  44.       }
  45.     }
  46.   }
  47. else {
  48.   print "empty";
  49.   }
  50. print "</html>";
  51.  
  52. sub show {
  53.     $_[0] = escapeHTML($_[0]);
  54.     $_[0] =~ s/\r\n/<br>/g;
  55.     $_[0] =~ s/\n/<br>/g;
  56.     return $_[0]; }
  57.  
Dec 10 '09 #12

100+
P: 109
Ok, I just tried the script. Apparently, it isn't making any posts into the DB as I'm using my test app to ensure records are being written. I'll continue to work with this but I do appreciate all the help you've been giving me thus far.
Dec 11 '09 #13

100+
P: 109
To manually test this, am I using the right syntax for the variable?

/cgi-bin/reading.cgi?value="<energywise><device>71827008778 4420</device><slice><time>20000103165315</time><t1>57.537</t1><t2>63.275</t2><c1>0</c1></slice></energywise>"
Dec 11 '09 #14

Expert Mod 100+
P: 589
Have you checked to see if your script is seeing the input data the way you think it should?

Add this just after printing the header.
Expand|Select|Wrap|Line Numbers
  1. my $value = param('value');
  2. print "'value' param = $value";

Why are you declaring $variable inside the param() and upload() calls?

That var should be declared and assigned prior to using it in those cgi function calls.
Dec 11 '09 #15

100+
P: 109
Ok, that makes sense...I'll refine the script.

What I got back from the input was this:
Expand|Select|Wrap|Line Numbers
  1. 'value' param = '7182700877844202000010316531557.53763.2750'
What I expected to see was XML formatted data like what is going into it. Like this:

Expand|Select|Wrap|Line Numbers
  1. <energywise><device>71827008778 4420</device><slice><time>20000103165315</time><t1>57.537</t1><t2>63.275</t2><c1>0</c1></slice></energywise>
Dec 11 '09 #16

100+
P: 109
I'm totally frustrated! I don't know why the script won't post to the database...Also, why is 'value' being formatted as a number instead of a string. Any help here would be most appreciated. I'll post my script again for help...

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl  
  2. use strict;  
  3. use warnings;  
  4. use CGI qw(:standard);  
  5. use CGI::Carp qw(fatalsToBrowser warningsToBrowser);  
  6. use DBI qw(:sql_types);  
  7.  
  8. my $title = 'Reading List';  
  9. my $start = 40;  
  10.  
  11. print header(), start_html($title), 
  12. h1({-style=>"font-size:1.2em"}, $title); 
  13. my $value = param("value");
  14. print "'value' param = $value";  
  15.  
  16. my $dbName = "MyDatabase";  
  17. my $dbHost = "192.168.1.160";  
  18. my $dbUser = "MyUser";  
  19. my $dbPass = "MyPass";  
  20. my $dbh = DBI->connect("DBI:mysql:$dbName:$dbHost", $dbUser, $dbPass, { RaiseError => 1 }) or die "Die: $DBI::errstr\n"; 
  21. my @fields = param(); 
  22. my @values = param(my $variable); 
  23. my @filehandles = upload(my $variable); 
  24.  
  25.  
  26. if(param()) { 
  27.   for $variable(@fields) { 
  28.     for my $value(@values) { 
  29.       if(@filehandles) { 
  30.         } 
  31.       else { 
  32.         $value =~ s/ / /g; 
  33.     if($value eq '') { 
  34.       } 
  35.     else { 
  36.       my $sql = "INSERT INTO ewise_raw_data_in (raw_id, raw_data_xml) VALUES (default,\"$value\")"; 
  37.       my $sth = $dbh->prepare($sql) || die "prepare: $sql: $DBI::errstr"; 
  38.       $sth->execute() || print "execute: $sql: $DBI::errstr"; 
  39.       $sth->fetchrow(); 
  40.       $sth->finish(); 
  41.       $dbh->disconnect(); 
  42.       print "12.3";    # content 
  43.       } 
  44.     } 
  45.       } 
  46.     } 
  47.   } 
  48. else { 
  49.   print "empty"; 
  50.   } 
  51. print "</html>"; 
  52.  
  53. sub show { 
  54.     $_[0] = escapeHTML($_[0]); 
  55.     $_[0] =~ s/\r\n/<br>/g; 
  56.     $_[0] =~ s/\n/<br>/g; 
  57.     return $_[0]; } 
  58.  
  59.  
Dec 16 '09 #17

Expert Mod 100+
P: 589
Please use proper indentation on your code blocks. It will make it much easier for you and use.

Read: perldoc perlstyle
http://perldoc.perl.org/perlstyle.html

Part of your problem is with these 2 lines.
Expand|Select|Wrap|Line Numbers
  1. my @values = param(my $variable); 
  2. my @filehandles = upload(my $variable); 
You need to read the CGI documentation for the param() and upload() functions. Apparently you don't fully understand how to use them.
http://search.cpan.org/~lds/CGI.pm-3.48/lib/CGI.pm

Why do you have these 2 if blocks that do absolutely nothing?
Expand|Select|Wrap|Line Numbers
  1. if(@filehandles) { 
  2. }
  3. # and this one
  4. if($value eq '') { 
  5. }
And why this regex?
Expand|Select|Wrap|Line Numbers
  1. $value =~ s/ / /g;
It substitutes a 'space' with a 'space'.
Dec 16 '09 #18

Post your reply

Sign in to post your reply or Sign up for a free account.