Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
Perl problem - cookies and MySQL, can anyone take a look?
Old 07-09-2007, 06:43 PM Perl problem - cookies and MySQL, can anyone take a look?
delighted's Avatar
Super Talker

Posts: 147
Trades: 0
I don't really know Perl. Still I do need to add a little something to a script. I've been thinking of using PHP::Interpreter and do my bit in PHP, but it just fails to install on the server.

Well this is the code, it's supposed to read a cookie (if the user is logged in) and check if he's got the correct password in a MySQL database. All I get is a 500 Internal server error

Code:
#!/usr/bin/perl

use DBI;
use CGI;
$query = new CGI;
print $query->header;

$username = $query->cookie('ID_FILES');
$password = $query->cookie('KEY_FILES');

if ($username) { 

    my $dbh = DBI->connect ("DBI:mysql:userbase:localhost", "login","pass") || die "Could not connect to database: " . DBI-> errstr;

    my $sql_stmnt = "SELECT * FROM users WHERE username = '$username'";
    my $sth = $dbh->prepare($sql_stmnt);
    $sth->execute();
    my $pass = $sth->fetchall_arrayref();
    $sth->finish();
    $dbh->disconnect();
    
    foreach my $record (@$pass){
        my ($username2, $password2) = @$record;
        if ($password ne $password2) { die "Must be signed in!\n"; }
    }
}

else {
   die "Must be signed in!\n";
}
Thanks...
__________________

Please login or register to view this content. Registration is FREE
- upload and share 500 MB files. No registration.
delighted is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-05-2007, 08:36 PM Re: Perl problem - cookies and MySQL, can anyone take a look?
Average Talker

Posts: 21
Name: Richard
Trades: 0
have you thought about loading fatalsToBrowser?

this will print error messages to the browser instead of just a 500 internal server error

Put this just above use DBI;

use CGI::Carp qw(fatalsToBrowser);
MrL22 is offline
Reply With Quote
View Public Profile
 
Old 08-11-2007, 10:17 AM Re: Perl problem - cookies and MySQL, can anyone take a look?
Skilled Talker

Posts: 77
Trades: 0
Try adding this line:

print "content-type: text/html\n\n";

put it under $password = xx & above the if clause.

Though, adding the use CGI::Carp qw(fatalsToBrowser); helps cuz it prints out your errors to your screen; very beneficial for bug fixing.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
whooligan is offline
Reply With Quote
View Public Profile
 
Old 08-14-2007, 12:08 AM Re: Perl problem - cookies and MySQL, can anyone take a look?
Junior Talker

Posts: 3
Name: Christey
Trades: 0
I'm not that great with perl, but I have noticed that if uploaded incorrectly scripts won't work....did you make sure to upload in binary instead of auto? Also if the perl path listed was the default, maybe your actual path is different. I'm sure you'll get more helpful responses...good luck to you.
PartyTeazer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Perl problem - cookies and MySQL, can anyone take a look?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.14799 seconds with 12 queries