We help IT Professionals succeed at work.

500 internal server error

RAXMAN
RAXMAN asked
on
208 Views
Last Modified: 2014-06-27
I have 2 pieces of code that i need to be debugged and ive ran them both through a debugger, but I get an internal server error everytime. I followed the instructions and searched around and everywhere says that I need to set permissions and put the files in the right folder on the server and I do have all that right, yet I still get this error. Anyone know any ideas why I still get this error? here's my code:

<html>
<head><title>Project 7</title>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body id = "p7">
<center>
   <h3>Enter story here</h3>
 
   <form action = "http://lab.cs.siu.edu/~dnaraine/cgi-bin/story2.cgi" method = "post">
 
   <textarea name = "name" rows="20"  cols="40"></textarea>
 
   <p>
   <input type = "submit" value= "Submit Form"/>
   <input type = "reset" value= "Reset"/>
   </p>
   </form>
   
  
 
 
</center>
</body>
</html>
 
 
 
AND
 
 
 
 
 
 
 
 
#!/usr/local/bin/perl
 
use CGI ":standard";
use Fcntl qw(:DEFAULT :flock);
 
sub error {
    print start_html();
    print "Error - input/output error <br/>";
    print end_html();
    exit(1);
}
 
 
      my($str) = (param("name"));
 
 
 
      $topword = "story.txt";
 
  
      open($topword, "a+") or die("Error - file cannot be opened");
      print($topword, $str);
      close($topword);
 
            
      print("<br /> Your story is about $topWord<br /><br />");

Open in new window

Comment
Watch Question

CERTIFIED EXPERT
Top Expert 2007

Commented:
Need to see your code, not the HTML.

Author

Commented:
scroll down more
Top Expert 2009
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Ive tried to make the code more basic. I cant see the error log because I dont own the server. The school does.

My code is actually more complicated than this code im posting, but im trying to get it working period. Ive tried MORE simpler codes by the teacher and his works, but not mine. So I dont get why my code is wrong.
#!/usr/local/bin/perl
 
use CGI ":standard";
use Fcntl qw(:DEFAULT :flock);
 
      my($str) = (param("name"));
 
      print header();
 
      $topword = "story.txt";
 
  
      open($topword, "a+") or die("Error - file cannot be opened");
      print($topword, $str);
      close($topword);
 
            
      print("<br /> Your story is about $topWord<br /><br />");
 
    
  

Open in new window

Top Expert 2009

Commented:
If what you posted isn't working, but simpler code does, the problem could be the open statement.  It is likely that the web server user does not have permission to open the file for writing - so your program dies.  If you add this to the top of your script, you'll get a more detailed error message:
    use CGI::Carp 'fatalsToBrowser';

Author

Commented:
yea you're right it says it cannot open the file in line 16 which is story.txt

how do i fix that? the file permissions are: rwxr-xr-x
Top Expert 2009
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.