Helpful Information
 
 
Category: Perl/ CGI
how do i

how do i add a image url to a cgi file as when i try i get a http 500 error :(

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

thanks dude :thumbsup:

thats alright..anytime.:)

i still got the http 500 error :(

ok post the bit of code that is causing the error and i`ll loook at it for ya:)

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.

could the post the bit of code right from the code and not from the error?
thanks
sir p

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

#!/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>

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

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 ?

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

so thats the problem i had :( whoops :D
got it working , thanks again dude :thumbsup:

anytime:)

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

Unless it is a small bit of code, don't waste your time escaping...use qq instead:



print qq~
This is text<br>that does not need escaping, even if it is "quoted" or &quot;quoted&quot; or <quote>quote</quote><br><br>even [email protected]~;


Note that it begins with print qq~ and ends with ~;, and will save you huge amounts of time when dealing with exceedingly large amounts of content.

is there a list of all the tags or what ever their called please ?

what do i need to put to make tables in the cgi file i am writing ?:confused:

welll if your writing to a txt or html file just use html to make it the <table> and <tr> etc

so i put it like this ? =

<table border=1 width=100% cellspacing=1 bgcolor="#cdcdcd">
<tr>

</tr>
</table>










privacy (GDPR)