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 08-15-2002, 12:46 PM   PM User | #1
marvinmartian
New to the CF scene

 
Join Date: Jul 2002
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
marvinmartian is an unknown quantity at this point
Unhappy Internal Server Errors

Good morning all,

Hopefully someone out there can shed some light for me on this issue. I have written a fairly simple script to pass data from a completed form to a database. It is a Unix environment passing data to an Oracle database. Unfortunately, when I tried to test the script, I get the dreaded "Internal Server Error". Can anybody help?

Thanks!


#!/usr/bin/perl
use CGI ':standard';
print "Content-type:text/html \n\n";

$firstname = param('firstname');
$lastname = param('lastname');
$street1 = param('street1');
$street2 = param('street2');
$city = param('city');
$state = param('states');
$zip = param('zipcode');
$email = param('email');
if (! $email) {$email="None";}
$userid = param('userid');
$password = param('password');

use DBI;
my $dbhandle = DBI->connect('DBI:Oracle:host=matrix.csis.pace.edu;sid=ORA1',dbname','dbpassword')|| "Could not connect to database:
".DBI->errstr;
my $sql="SELECT USERID from customers where USERID = '$userid'";

my $sqlstmt=$dbhandle->prepare($sql);
$sqlstmt->execute();
@ret = $sqlstmt->fetchrow_array();
if ($ret[0] eq $userid)
{
print <<rm
<html>
<body>

<div align="center">

<h1><center><font face=size=30 color="yellow"><i> random text</i></font></center></h1>
<h3><center><font color="yellow">more random text</font></center></h3></div>
<br>
<br>
<br>

<CENTER> <B> The Userid <u>$userid</u> you have chosen is already in use.<br> Please select a different Userid </B> </CENTER>
</body></html>
rm
;
}
else
{

my $sql = "INSERT INTO customers VALUES ('$userid','$firstname', '$lastname', '$street1', '$street2', '$city', '$state', '$zip', '$email', '$password')";

my $sqlstmt=$dbhandle->prepare($sql);
$sqlstmt->execute();
$sqlstmt->finish;
$dbhandle->disconnect;

print<<regi
<html>
<head>
<title> Thank You!</title>

<script language="JavaScript">
<!--
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function SearchValid()
{
if(document.searchbar.searchstring.value=="")
{
alert("Please enter a value");
return false;
}
return true;
}
//-->
</script>
</head>

<body bgcolor="#669999" onLoad="MM_preloadImages('about_us_over.GIF','register_over.GIF','contact_us_over.GIF','shop_over.GI F','checkout_over.GIF')" text="#FFFF00">

<table border="0" width="600">
<tr>
<td>
<img border="0" src="../ProjectImages/our_name_banner.GIF" alt="co. name" align="left" width="500" height="100">
</td>
<td width="50">
</td>
<td>
<img src="../ProjectImages/cart.gif" alt="cart">
</td>
<td width="50">
</td>
<td>
<a href="index.html">
<img src="../ProjectImages/home.gif" alt="home" border="0">
</a>
</td>
</tr>
</table>

<table border="0" width="600">
<tr>
<td width="41">
<p align="center"><a href="aboutus.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('aboutus','','../ProjectImages/about_us_over.GIF',1)"><img src="../ProjectImages/about_us.GIF" width="144" height="45" name="aboutus" border="0" alt="About Us"></a></p></td>
<td width="121">
<p align="center"><a href="register.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('register','','../ProjectImages/register_over.GIF',1)"><img src="../ProjectImages/register.GIF" width="144" height="45" name="register" border="0" alt="Register"></a></p></td>
<td width="142">
<p align="center"><a href="mailto:whocares@yahoo.com" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('contact_us','','../ProjectImages/contact_us_over.GIF',1)"><img src="../ProjectImages/contact_us.GIF" width="145" height="45" name="contact_us" border="0" alt="Contact Us"></a></p></td>
<td width="148">
<p align="center"><a href="checkout.html" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('checkout','','../ProjectImages/checkout_over.GIF',1)"><img src="../ProjectImages/checkout.GIF" width="144" height="45" name="checkout" border="0" alt="Checkout"></a></p></td>

<td align="right">

<form method="search" name="searchbar" action="post">
<p align="right"><input type="text" name="searchstring" size="25"><br>
<select size="1" name="searchby">
<option selected>select a type..</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select><input type="button" value="Search" name="Search" onClick="return SearchValid()"></p>
</form>

</td>
</tr>

<head><title>Thank You For Registering</title></head>

<div align=center>
<h3>Thank you <b>$firstname</b> for registering with us.<br>
The following information has been registered:<br><br>
First Name: <b>$firstname</b><br>
Last Name: <b>$lastname</b><br>
USERID: <b>$userid</b><br>
Address: <b>$street1</b><br> <b>$street2</b><br>
City: <b>$city</b><br>
State: <b>$state</b><br>
ZIP: <b>$zip</b><br>
EMAIL: <b>$email</b><br>

</h3>
</div>
</body>
</html>
regi
;


}
marvinmartian is offline   Reply With Quote
Old 08-15-2002, 12:53 PM   PM User | #2
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
If you have access to the logfiles, have a look in the error logfile and find the problem. Or, if you don't have access to these logfiles, use
use CGI::Carp "fatalsToBrowser";
This will show the exact error in the browser, when the page is visited.

Hope this helps (a little)

Mzzl, Chris
chrisvmarle is offline   Reply With Quote
Old 08-30-2002, 08:47 PM   PM User | #3
Inci
New Coder

 
Join Date: Aug 2002
Location: Moscow, RU
Posts: 23
Thanks: 0
Thanked 1 Time in 1 Post
Inci is an unknown quantity at this point
If you have linux hosting - you will have to upload your script as TEXT (ASCII mode) and set permissions like 700 or 770 (execution) by calling "chmod 700 your script name"

Hope this will help you.
Inci is offline   Reply With Quote
Old 08-31-2002, 01:41 PM   PM User | #4
Mouldy_Goat
Regular Coder

 
Join Date: Jul 2002
Location: London, UK
Posts: 126
Thanks: 0
Thanked 0 Times in 0 Posts
Mouldy_Goat is an unknown quantity at this point
There's a problem with this line here:
Code:
my $dbhandle = DBI->connect('DBI:Oracle:host=matrix.csis.pace.edu;sid=ORA1',dbname','dbpassword') || 
"Could not connect to database: ".DBI->errstr;
As you can see you're missing one single quote just before dbname. Also, I'm not sure it's a great idea to assign a string to $dbhandle if the connect fails... you probably meant something like:

Code:
my $dbhandle = DBI->connect('DBI:Oracle:host=matrix.csis.pace.edu;sid=ORA1','dbname','dbpassword') || 
die "Could not connect to database: ".DBI->errstr;
Apart from that though I can't really see anything immediately..
Mouldy_Goat is offline   Reply With Quote
Old 09-03-2002, 12:47 PM   PM User | #5
marvinmartian
New to the CF scene

 
Join Date: Jul 2002
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
marvinmartian is an unknown quantity at this point
Thanks everybody for your thoughts/input....

Inci, I had already thought of that and set chmod to755

Goat, thank you for taking the time to carefully read the script and notice the single quote that I missed. I have not had the opportunity to test it again, but I'm sure that catch will make a great difference in how it runs.

Thanks again!
marvinmartian 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 01:13 PM.


Advertisement
Log in to turn off these ads.