CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
newbie trying to find problem in script...

 



jcs
Deleted

Jun 4, 2001, 10:23 AM

Post #1 of 6 (748 views)
newbie trying to find problem in script... Can't Post

I have written a script which takes info. from an html form and sends it to access and updates the info. in a new page. The first time I run the script it is fine, but then it breaks. I have tried to place simple print statements in the script to determine where it breaks and it seems it breaks at the third 'if' statement in the file jobaddTest.pl... I have spent many days trying to figure out what is wrong and I need some help. I have attached the pl file, if anyone can help it would be much appreciated. Thanks. Jen



mhx
Enthusiast / Moderator

Jun 4, 2001, 2:35 PM

Post #2 of 6 (740 views)
Re: newbie trying to find problem in script... [In reply to] Can't Post

It seems there's currently some kind of problem in this forum concerning posts with attachments. They cannot be downloaded. Even an attachment I've posted several days ago, and which worked fine then, cannot be downloaded. So either you put that file somewhere where it can be accessed, or someone tries to find a solution to the download problem...
Sorry, no code - no help...

-- Marcus



Jasmine
Administrator / Moderator

Jun 4, 2001, 3:28 PM

Post #3 of 6 (739 views)
Re: newbie trying to find problem in script... [In reply to] Can't Post

mhx,

What problem are you seeing with the attachments? They're working fine -- http://forums.perlguru.com/uploads/2-10791-jobaddTest.pl.txt. Contents of file attached to the previous post is:


Code
#!/usr/bin/perl 
use CGI qw(:all);

use File::Basename;
chdir(dirname($0));
require "toolbox.pl";

$\ = "\n";
$, = "\n";
$" = "\n";

print header;
print start_html ("database test");

$jobtitle = param("JobTitle");
$jobdes = param("JobDescription");


if ($jobtitle && $jobdes) {
&DB_connect;
} else {
print ("Please fill in all fields"),
end_html;
}


sub DB_connect {

use DBI;
unless ($dbh = DBI->connect("DBI:ODBC:jobs")) {
$conn_error = DBI->errstr;
print "<h2>Failed to connect: $conn_error",
end_html;
exit;
}

$jobtitle = $dbh->quote($jobtitle);
$jobdes = $dbh->quote($jobdes);

$statement = "INSERT INTO jobsTest
(JobTitle, JobDescription)
VALUES ($jobtitle, $jobdes)";

if ($sth = $dbh->prepare($statement)) {
$returncode = $sth->execute;
} else {
$prep_error = $dbh->errstr;
print "SQL Syntax Error",
end_html;
}


if ($returncode) {
$sth->finish;
&RetrieveMatches;
&PrintResults;
} else {
$data_error = $dbh->errstr;
print "SQL Execution Error",
end_html;
}
}

sub RetrieveMatches {
$statement2 = "SELECT * FROM jobsTest
WHERE JobTitle = $jobtitle AND JobDescription = $jobdes
ORDER BY JobTitle DESC";

$sth2 = $dbh->prepare($statement2);
$prep_error = $dbh->errstr;

if ($sth2) {
$returncode = $sth2->execute;
} else {
print "SQL Error: $prep_error",
end_html;
exit;
}
}

sub PrintResults {
print "<center>jobs
<table border>
<tr>
<th>Job Title</th>
<th>Job Description</th>
</tr>";

while (@row = $sth2->fetchrow_array) {
print "<tr>";
print "<td>$row[0]</td>";
print "<td>$row[1]</td>";
print "</tr>";



print "</table></center>";

print "<a href=\"jobaddTestDisplay.pl\">Display Changes</a>",
end_html;
}
$sth2->finish;
$dbh->disconnect;
}



Pro_4
User

Jun 4, 2001, 4:34 PM

Post #4 of 6 (735 views)
Re: newbie trying to find problem in script... [In reply to] Can't Post

Jasmine,

I am having that same problem, i clicked that link you provided and still nothing came up.

? Thats odd how you can see it and not us.

Error: There is a problem with the page you are trying to reach and it cannot be displayed.

Maybe that will help.

Yes i am a palm tree. What are you plantist or something!?


mhx
Enthusiast / Moderator

Jun 5, 2001, 12:36 AM

Post #5 of 6 (731 views)
Re: newbie trying to find problem in script... [In reply to] Can't Post

Hi Jasmine,

it seems to be a very funny problem. On my machine (which I have to run Win98 on) I cannot download the attachment with either a left or a right click. I receive the same error as Pro_4. On the NT machine I'm actually sitting in front of, I can left-click and it's displayed in the browser, if I right-click, it cannot be downloaded. I guess this is mainly a problem with my (and Pro_4's) file association setup in the registry, so the browser always tries to download .txt files.
What makes me wonder is that they can be displayed, but not downloaded. I'm quite sure that this worked some days ago...
Anyway, perhaps I'll just write a little LWP::Simple script to get that download thing done without the 'help' of InternetExplorer Wink.

-- Marcus



jcs
Deleted

Jun 5, 2001, 5:14 AM

Post #6 of 6 (722 views)
Re: newbie trying to find problem in script... [In reply to] Can't Post

Sorry about you not being able to get the code but now that someone has been nice enough to post it on the forum, does anyone have any suggestions as to what might be the problem?

Thanks for your help.

Jen


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives