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: Beginner:
I'd really apreciate it if someone could help...

 



SaiyanM
User

Jul 7, 2001, 11:30 AM

Post #1 of 5 (760 views)
I'd really apreciate it if someone could help... Can't Post

I made this button exchange script. When a user fills it out but leaves one or more feilds blank, it pops up a download screen to download one of the images being used in the script. However, instead of having the pop-up screen show up, i want an error message saying that "you left something blank". Heres the script...

#!/usr/local/bin/perl/
##########################
# Saiyan Menacy Button Exchange V1.0
# 1999-2001 ChibiGuy Productions
# Don't bother stealing this, what good is it gonna do?
# E-mail me at Saiyan M@hotmail.com
# Feel free to re-distribute this script as many times as you want
# however, please do not try to sell this script
# and if you change the script to your liking,
# let me see it and ill tell you if it is okay
##########################

##Variables
use CGI qw/:standard/;
$sitename = param('sitename');
$url = param('url');
$buttonurl = param('buttonurl');
$header_url = "/Layouts/header.txt";
$footer_url = "/Layouts/footer.txt";
$blank_error = "You left something blank";


##Check the entry to see if anything is blank
if(($sitename eq "")||($url eq "")||($buttonurl eq ""))
{print "$blank_error";
}


##Add the button snippet to the .txt file
open(addbutton, ">>/data1/virtualave.net/saiyanh/public_html/cgi-bin/bexchange/buttons.txt");
print addbutton<<END;

<table cellpadding="0" cellspacing="0">
<tr><td colspan="2" bgcolor="black"><font Color="white" size="1" face="arial"><centeR>SaiyanM Exchange</font></td></tR>
<tr><td><a href="http://saiyanh.virtualave.net/cgi-bin/bexchange/add.html"><img src="http://saiyanh.virtualave.net/cgi-bin/bexchange/bexchange_start.gif" border="0"><div align="left"></td>
<td><a href="$url"><img src="$buttonurl" alt="$sitename; Part of the Saiyan Menacy Exchange" border="0" width="88" height="31"></a></td></tr></table>

END
close(addbutton);



##Thanks
print "Content-type: text/html\n\n";
print <<THANKS;

THANKS


Thanks for anyone who tries to help :)



The script is at http://saiyanh.virtualave.net/cgi-bin/bexchange/add.html if you want to see it




(This post was edited by SaiyanM on Jul 7, 2001, 10:47 AM)


randor
User

Jul 7, 2001, 4:31 PM

Post #2 of 5 (750 views)
Re: I'd really apreciate it if someone could help... [In reply to] Can't Post

Try this:

#!/usr/local/bin/perl/
##########################
# Saiyan Menacy Button Exchange V1.0
# 1999-2001 ChibiGuy Productions
# Don't bother stealing this, what good is it gonna do?
# E-mail me at Saiyan M@hotmail.com
# Feel free to re-distribute this script as many times as you want
# however, please do not try to sell this script
# and if you change the script to your liking,
# let me see it and ill tell you if it is okay
##########################

##Variables
use CGI qw/:standard/;
$sitename = param('sitename');
$url = param('url');
$buttonurl = param('buttonurl');
$header_url = "/Layouts/header.txt";
$footer_url = "/Layouts/footer.txt";
$blank_error = "You left something blank";


##Check the entry to see if anything is blank
&error('sitename') unless ($param('sitename'));
&error('buttonurl') unless ($param('buttonurl'));
&error('url') unless ($param('url'));


sub error {
print "Content-type: text/html\n\n";
print "You did not fil out $_[0]\n";
}


##Add the button snippet to the .txt file
open(addbutton, ">>/data1/virtualave.net/saiyanh/public_html/cgi-bin/bexchange/buttons.txt");
print addbutton<<END;

<table cellpadding="0" cellspacing="0">
<tr><td colspan="2" bgcolor="black"><font Color="white" size="1" face="arial"><centeR>SaiyanM Exchange</font></td></tR>
<tr><td><a href="http://saiyanh.virtualave.net/cgi-bin/bexchange/add.html"><img src="http://saiyanh.virtualave.net/cgi-bin/bexchange/bexchange_start.gif" border="0"><div align="left"></td>
<td><a href="$url"><img src="$buttonurl" alt="$sitename; Part of the Saiyan Menacy Exchange" border="0" width="88" height="31"></a></td></tr></table>

END
close(addbutton);


I think this is what you want, let me know if i am wrong, also i did not test this, but there is no reason to think it shouldnt work, but if it doesnt let me know also.



I Hope this helps...

perl programmers don't die.. they just start writing a new script.


SaiyanM
User

Jul 8, 2001, 1:36 PM

Post #3 of 5 (740 views)
Re: I'd really apreciate it if someone could help... [In reply to] Can't Post

Thanks for trying but i get this error. This is what appears in my cgi error log...

syntax error at /home/public_html/cgi-bin/bexchange/bexchange.cgi line 24, near "$param("
syntax error at /home/public_html/cgi-bin/bexchange/bexchange.cgi line 25, near "$param("
syntax error at /home/public_html/cgi-bin/bexchange/bexchange.cgi line 26, near "$param("
Execution of /home/public_html/cgi-bin/bexchange/bexchange.cgi aborted due to compilation errors.
syntax error at /home/public_html/cgi-bin/bexchange/bexchange.cgi line 24, near "$param("
syntax error at /home/public_html/cgi-bin/bexchange/bexchange.cgi line 25, near "$param("
syntax error at /home/public_html/cgi-bin/bexchange/bexchange.cgi line 26, near "$param("
Execution of /home/public_html/cgi-bin/bexchange/bexchange.cgi aborted due to compilation errors


*the red is the same error twice



mhx
Enthusiast / Moderator

Jul 8, 2001, 2:02 PM

Post #4 of 5 (739 views)
Re: I'd really apreciate it if someone could help... [In reply to] Can't Post

Hi,

the only thing I can currently figure out is that there's a terminating slash in the shebang line that is definetely wrong. I'm not sure if this will lead to the errors you receive, but it's worth a try. Also, you should put at least a '-w' in that line, making it look like this:

Code
#!/usr/local/bin/perl -w

-- Marcus



PerlKid
stranger

Jul 8, 2001, 8:23 PM

Post #5 of 5 (732 views)
Re: I'd really apreciate it if someone could help... [In reply to] Can't Post

Param is a subroutine, not a variable. Just remove the $ and you'll be fine.

Change stuff like:

Code
&error('buttonurl') unless ($param('buttonurl'));

To:

Code
&error('buttonurl') unless (param('buttonurl'));

Also note that you cannot interpolate them... (ie, print "someting param('foo')";)

--Drew
http://www.camelsoup.com

Code
s;[\d\$&(\^)];;g+s;\.; ;g+s;(.)(..);$2$1;g+print,if$_='&61k4I.)l6il.edn7(K2e^ny$';


 
 


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

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