Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

what is the problem in this script and why it makes error

Posted on 2009-07-02
3
Medium Priority
?
206 Views
Last Modified: 2013-12-25
i have the attached script when I enter data and press the button it prints ok then display error message and I don't know why
I commented 2 lines because they made error
#use lib qw(/opt/lampp/bin/perl);
#use WebDB;
can you please tell me how to make the script work without comments
also this line I don't know what does it means
#@ MAIN_LOGIC
#@ INSERT_ITEM
#@ DISPLAY_ENTRY_FORM
please help as soon as possible
best regards
hatem gamal
#! /opt/lampp/bin/perl -w
#@ MAIN_LOGIC
# todo1.pl - initial version of to-do application
 
use strict;
#use lib qw(/opt/lampp/bin/perl);
use CGI qw(:standard);
#use WebDB;
 
print header (),
	start_html (-title => "To-Do List", -bgcolor => "white"),
	h2 ("To-Do List");
 
# Dispatch to proper action based on user selection
 
my $choice = lc (param ("choice"));	# get choice, lowercased
 
if ($choice eq "")					# initial script invocation
{
	display_entry_form ();
}
elsif ($choice eq "submit")
{
	insert_item (param ("content"));
	display_entry_form ();
}
else
{
	print p ("Logic error, unknown choice: $choice");
}
 
print end_html ();
#@ MAIN_LOGIC
 
exit (0);
 
# ----------------------------------------------------------------------
 
# Insert new to-do item if the content is non-empty.
 
#@ INSERT_ITEM
sub insert_item
{
my $content = shift;
my $dbh;
 
	$content =~ s/^\s+//;	# strip leading whitespace
	$content =~ s/\s+$//;	# strip trailing whitespace
	if ($content ne "")		# if content is non-empty, add to table
	{
		$dbh = WebDB::connect ();
		$dbh->do (qq{
			INSERT INTO todo SET t = NOW(), status = 'open', content = ?
				}, undef, $content);
		$dbh->disconnect ();
	}
}
#@ INSERT_ITEM
 
# Display entry form
 
#@ DISPLAY_ENTRY_FORM
sub display_entry_form
{
	print start_form (-action => url ()),
		"To-do item:", br (),
		textarea (-name => "content",
					-value => "",
					-override => 1,
					-rows => 3,
					-columns => 80),
		br (),
		submit (-name => "choice", -value => "Submit"),
		end_form ();
}
#@ DISPLAY_ENTRY_FORM

Open in new window

0
Comment
Question by:hatem_from_mesr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 7

Assisted Solution

by:Fairlight2cx
Fairlight2cx earned 1400 total points
ID: 24763193
On the very first line, remove the space at position 3 after the #! sequence.
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 600 total points
ID: 24771595
It would have been very helpful if you had posted the actual errors.

Line 6 will not generate any errors by itself, but it is incorrect as it should be a directory and not a filename.

Line 8 will get an error if the WebDB module is not installed in any of the standard Perl paths or in the path defined in line 6 (which is obviously the incorrect path)
0
 
LVL 7

Accepted Solution

by:
Fairlight2cx earned 1400 total points
ID: 24771683
By the way...

The #@ lines look to be someone's private convention for starting and stopping a block of code--notes to themselves, essentially.
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question