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:
transfer site from linux to windows, DBI problem?

 



malachi
Novice

Dec 12, 2012, 3:10 AM

Post #1 of 7 (1364 views)
transfer site from linux to windows, DBI problem? Can't Post

Hello,

We have a old website that was running on linux/apache server. The server brokedown and I need to transfer the site to diffrent server.

I am not familiar with cgi scripts and I have a problem.

Diffrent server is apache 2.2.11 with php 5.2.9 on windows 2003 SBS.

I have installed ActivePerl 5.14.2 with DBI, DBD-ODBC packages.

I rewrite some lines in script so it would work on Windows.

Everything seems to work ok but when the script verify login data it gives login error.

He is my script:

#!C:\perl\bin\perl.exe -w

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

use DBI;

my $server = "my_serwer"; my $login = "mylogin"; my $haslo = "mypassword";

my $Error = 0;my $ErrorDBI = "";

#eval { DBI->trace(4) };

#if ($@) # {# $ErrorDBI = $@;# $Error = 6;# }use CGI;

$cgi = new CGI;

$user_name = $cgi->param("user_name");

$password = $cgi->param("password");

use CGI::Carp qw (fatalsToBrowser);

print "<html>";print "<head>\n";print "<meta http-equiv='Content-Type' content='text/html; charset=windows-1250'>";

print "<meta http-equiv='EXPIRES' content='0'>";

print "</head>\n";

my $conn=DBI->connect("dbi:ODBC:$server", $login, $haslo) or die "Error in connect $DBI::errstr ";

$dbh = $conn->prepare("SELECT password, id_kom, id_ko FROM webklient where user_name='$user_name'") or die "Can't prepare statement: $DBI::errstr";

$dbh->execute or die "Can't execute statement: $DBI::errstr";$dbh->bind_columns(\($pass_d,$kntr_id_kom, $kntr_id_ko));

if ($dbh->fetch) { if ($pass_d ne $password) { $Error = 3;

print "wrong password\n";

print "$pass_d \n"; -- here it shows "te" and in database is "test123" ????

print "$password \n"; -- here it shows "test123" this is correct

print "$user_name \n"; -- here it shows "test123" this is correct

}

else...

I don't know where is the problem. The Select statment should return 'test123' for user 'test123' but it only retuns first two characters 'te'.

When I compare user password from POST with the one form database it is incorrect.

Is it ActivePerl, DBI problem or something else?

Please help.

Andrew


(This post was edited by malachi on Dec 12, 2012, 4:19 AM)


FishMonger
Veteran / Moderator

Dec 12, 2012, 7:03 AM

Post #2 of 7 (1357 views)
Re: [malachi] transfer site from linux to windows, DBI problem? [In reply to] Can't Post

Your script has lots of problems, but for the moment I'll keep to the question regarding the password issue you're seeing.

The problem is not with Activestate Perl or the DBI module. Perl will fetch/return whatever it finds in the database and will not truncate that data unless you specifically do so in your code.

I suspect that you have multiple entries in the DB for this user and the first record that is retrieved has the wrong value in the password field.


malachi
Novice

Dec 12, 2012, 12:10 PM

Post #3 of 7 (1352 views)
Re: [FishMonger] transfer site from linux to windows, DBI problem? [In reply to] Can't Post

Hello,
Thanks for your reply.
I checked on the database and there is just one entry for user test123 and the password is "test123". So why I just get "tes" when I print? ( my mistake in first post - I get "tes"not "te")
I also changed select statment to this:
"Select 'hello', id_kom from webklient where user='$user_name'"
and again when I print first column which is string "hello" I just get 2 characters "he".
If this was problem with data I should get "hello"?
When I selected from column it was 3 characters "tes" isn't this strange?


(This post was edited by malachi on Dec 12, 2012, 12:23 PM)


FishMonger
Veteran / Moderator

Dec 12, 2012, 12:19 PM

Post #4 of 7 (1348 views)
Re: [malachi] transfer site from linux to windows, DBI problem? [In reply to] Can't Post

What database are you using?

What do you get when you execute the select statement from the database cli?

Can you post a print screen of the cli output and your script output?


malachi
Novice

Dec 12, 2012, 12:37 PM

Post #5 of 7 (1346 views)
Re: [FishMonger] transfer site from linux to windows, DBI problem? [In reply to] Can't Post

This is very old Sybase Adaptive Server Anywhere 6.

when I execute in InteractiveSQL this statment:
SELECT password, id_komor, id_kontr FROM webklient where user_name='test123'
The result is:
password id_komor id_kontr
test123 test 3

When I do print function in script I get:
password id_komor id_kontr
tes te 3


(This post was edited by malachi on Dec 12, 2012, 12:41 PM)


malachi
Novice

Dec 12, 2012, 12:51 PM

Post #6 of 7 (1342 views)
Re: [FishMonger] transfer site from linux to windows, DBI problem? [In reply to] Can't Post

I run some more statments and did some changes in script statment and it looks like I always get just half of the string that is on database.
When in column password is "test" I get "te" when it is "testtest" I get "test".
??


malachi
Novice

Dec 13, 2012, 11:18 AM

Post #7 of 7 (1326 views)
Re: [FishMonger] transfer site from linux to windows, DBI problem? [In reply to] Can't Post

Any help?

 
 


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

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