Go Back   CodingForums.com > :: Server side development > Perl/ CGI

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-24-2002, 01:48 AM   PM User | #1
chaotic
New Coder

 
Join Date: Jun 2002
Location: chaoticrealities.com
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
chaotic is an unknown quantity at this point
how do i

how do i add a image url to a cgi file as when i try i get a http 500 error
chaotic is offline   Reply With Quote
Old 06-24-2002, 02:30 AM   PM User | #2
sir pannels
Regular Coder

 
Join Date: Jun 2002
Posts: 905
Thanks: 23
Thanked 5 Times in 5 Posts
sir pannels is an unknown quantity at this point
you need to escape bits of it
so say you got for example
<img src="pics/pic.gif" border="0"> etc you get the idea
you need to escape the "`s so if you had that you`d need to replace it with
<imh src=\"pics/pic.gif\" boder=\"0\">
ok?
sir p
sir pannels is offline   Reply With Quote
Old 06-24-2002, 02:34 AM   PM User | #3
chaotic
New Coder

 
Join Date: Jun 2002
Location: chaoticrealities.com
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
chaotic is an unknown quantity at this point
thanks dude
chaotic is offline   Reply With Quote
Old 06-24-2002, 02:40 AM   PM User | #4
sir pannels
Regular Coder

 
Join Date: Jun 2002
Posts: 905
Thanks: 23
Thanked 5 Times in 5 Posts
sir pannels is an unknown quantity at this point
thats alright..anytime.
sir pannels is offline   Reply With Quote
Old 06-24-2002, 03:29 AM   PM User | #5
chaotic
New Coder

 
Join Date: Jun 2002
Location: chaoticrealities.com
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
chaotic is an unknown quantity at this point
i still got the http 500 error
chaotic is offline   Reply With Quote
Old 06-24-2002, 12:42 PM   PM User | #6
sir pannels
Regular Coder

 
Join Date: Jun 2002
Posts: 905
Thanks: 23
Thanked 5 Times in 5 Posts
sir pannels is an unknown quantity at this point
ok post the bit of code that is causing the error and i`ll loook at it for ya
sir pannels is offline   Reply With Quote
Old 06-24-2002, 02:00 PM   PM User | #7
chaotic
New Coder

 
Join Date: Jun 2002
Location: chaoticrealities.com
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
chaotic is an unknown quantity at this point
i might have got it wrong but here you go =

Software error:
syntax error at cbsboard.cgi line 62, near "<IMG SRC="http://www.chaoticrealities.com/cbs.gif" ALIGN="TOP" WIDTH="300" HEIGHT="100"><"
Execution of cbsboard.cgi aborted due to compilation errors.
chaotic is offline   Reply With Quote
Old 06-24-2002, 02:37 PM   PM User | #8
sir pannels
Regular Coder

 
Join Date: Jun 2002
Posts: 905
Thanks: 23
Thanked 5 Times in 5 Posts
sir pannels is an unknown quantity at this point
could the post the bit of code right from the code and not from the error?
thanks
sir p
sir pannels is offline   Reply With Quote
Old 06-24-2002, 03:08 PM   PM User | #9
chaotic
New Coder

 
Join Date: Jun 2002
Location: chaoticrealities.com
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
chaotic is an unknown quantity at this point
Internet Explorer

well here is all the code i have to date , it works fine when i take the image out =

#!/usr/bin/perl
###########################################

###################################################

use CGI::Carp qw(fatalsToBrowser);
print "Content-type:text/html\n\n";
print "<html><head><title>CBSForums</title></head>\n\n";
print "<body>\n";
print "<p><H1><center>CBSBoard</center></H1><H4><center>Out of chaos , comes a community...</center></H4></p>\n";
$file = 'data.txt' ; # Name the file
open(INFO, "<$file" ) ; # Open the file
@lines = <INFO> ; # Read it into an array
close(INFO) ; # Close the file
print " <BODY>\n" ;
foreach $line (@lines) # assign @lines to $line, one at a time
{ # braces {} are required, bracket code
print "\n <P> $line </P>" ; # print formatted lines to screen
}
##################################################################################
$correctUsername = "*****";
$correctPassword = "*****";



#################
# Form Data Parsing

if ($ENV{'REQUEST_METHOD'} eq 'GET') { $buffer = $ENV{'QUERY_STRING'}; }
else { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); }

@pairs = split(/&/, $buffer);

foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}

################
# Comparison

#Use a nested if/else statement like the one below to make debugging
#much easier
if ($FORM{'username'} eq $correctUsername) {
if($FORM{'password'} eq $correctPassword) { print "You've passed the test!\n"; }
else { print "Password Incorrect.\n"; }
}

else { print "Username Incorrect.\n"; }

######################
<P ALIGN="CENTER"><A HREF="http://www.chaoticrealities.com/cgi-bin/cbsboard/cbsboard.cgi"><IMG SRC="http://www.chaoticrealities.com/cbs.gif" ALIGN="TOP" WIDTH="300" HEIGHT="100"></A></P>

Last edited by chaotic; 06-24-2002 at 03:11 PM..
chaotic is offline   Reply With Quote
Old 06-24-2002, 03:27 PM   PM User | #10
sir pannels
Regular Coder

 
Join Date: Jun 2002
Posts: 905
Thanks: 23
Thanked 5 Times in 5 Posts
sir pannels is an unknown quantity at this point
yeh you didnt escape it...
change
<P ALIGN="CENTER"><A HREF="http://www.chaoticrealities.com/cgi-bin/cbsboard/cbsboard.cgi"><IMG SRC="http://www.chaoticrealities.com/cbs.gif" ALIGN="TOP" WIDTH="300" HEIGHT="100"></A></P>

to this
<P ALIGN=\"CENTER\"><A HREF=\"http://www.chaoticrealities.com/cgi-bin/cbsboard/cbsboard.cgi\"><IMG SRC=\"http://www.chaoticrealities.com/cbs.gif\" ALIGN=\"TOP\" WIDTH=\"300\" HEIGHT=\"100\"></A></P>
and it will work fine
sir p
sir pannels is offline   Reply With Quote
Old 06-24-2002, 03:38 PM   PM User | #11
chaotic
New Coder

 
Join Date: Jun 2002
Location: chaoticrealities.com
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
chaotic is an unknown quantity at this point
now i get this =

syntax error at cbsboard.cgi line 60, near "center>"
(Might be a runaway multi-line "" string starting on line 56)
Unrecognized character \xA9 at cbsboard.cgi line 60.

would it be easier if i did it in php ?

Last edited by chaotic; 06-24-2002 at 04:18 PM..
chaotic is offline   Reply With Quote
Old 06-24-2002, 06:24 PM   PM User | #12
sir pannels
Regular Coder

 
Join Date: Jun 2002
Posts: 905
Thanks: 23
Thanked 5 Times in 5 Posts
sir pannels is an unknown quantity at this point
no,

i see what you done now...your not printing it your just using html...you must print html like this...

print"<P ALIGN=\"CENTER\"><A HREF=\"http://www.chaoticrealities.com/cgi-\n";
etc..make sure every line is inside print" " ;
ok?
sir p
sir pannels is offline   Reply With Quote
Old 06-24-2002, 07:01 PM   PM User | #13
chaotic
New Coder

 
Join Date: Jun 2002
Location: chaoticrealities.com
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
chaotic is an unknown quantity at this point
so thats the problem i had whoops
got it working , thanks again dude

Last edited by chaotic; 06-24-2002 at 07:17 PM..
chaotic is offline   Reply With Quote
Old 06-24-2002, 08:56 PM   PM User | #14
sir pannels
Regular Coder

 
Join Date: Jun 2002
Posts: 905
Thanks: 23
Thanked 5 Times in 5 Posts
sir pannels is an unknown quantity at this point
anytime
sir pannels is offline   Reply With Quote
Old 06-24-2002, 09:45 PM   PM User | #15
chrisvmarle
Regular Coder

 
Join Date: Jun 2002
Location: the Netherlands
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
chrisvmarle is an unknown quantity at this point
I've been wondering what characters to escape...

Can you (SirP) or anyone tell me wich?

The ones I ALWAYS escape:
<
>
&
$
^
\
/
"
'

That's about it...

Mzzl, Chris
chrisvmarle is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:10 PM.


Advertisement
Log in to turn off these ads.