Forum Moderators: coopster & phranque

Message Too Old, No Replies

[ Perl Noob ] Serialization Base64 from PHP

         

Devil0

3:57 am on May 18, 2008 (gmt 0)

10+ Year Member



Hello,

My first post ..

if you wondering .. probably yes iam the kind of people who ask and get the answer and run to continue working ..

but i really apreciate any help :D and i guess it's easy one for a PERL expert ..

I have a PHP script contains this array :

#start :
-- Array
-- (

------ [0] => Array
------ (
----------- [ext] => jpg
----------- [size] => 100000
------- )

----- [1] => Array
----- (
----------- [ext] => zip
----------- [size] => 100000
----- )

-- )
#end

(ignore Dash - just to make it clear)

I did :
$arr = serilize($arr);
$arr = base64_encode($arr);
// Say output = ABC

I send the following to upload.cgi :
upload.cgi?arr=ABC

So, I want to :
#1 decode $queryString{"arr"} base64
#2 unseriliaze $queryString{"ser"}
#3 put it in an array in the same order to operate whatever i want throught loops :D

I kept trying .. but always ends with blank page or internal error .. and no RESULT !

any help ? or any ideas .. i would be glade to make some efforts to have my script done ..

chorny

8:51 am on May 18, 2008 (gmt 0)

10+ Year Member



There is PHP::Serialization on CPAN, but you may need to ping author and fix bugs. Also you can try cross-language serializations, like YAML (or JSON).

Perl has a very good documentation, use it. Perl has no operators 'decode' or 'unserialize'.

Devil0

7:34 pm on May 18, 2008 (gmt 0)

10+ Year Member



well i think it's complicated ..

well .. i have tried to create a connection with MySQL db .. but ..


#!c:/perl/bin/perl.exe

use CGI ':standard', '-debug';
use DBI;

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

$dbh = DBI->connect("dbi:mysql:database=zz; host=localhost; user=root; password=")
or die "Connecting from PHP to MySQL database failed: $DBI::errstr";
print "test";

it prints nothing .. Blank Page !

i die to see just 1 error !

chorny

8:08 pm on May 18, 2008 (gmt 0)

10+ Year Member


#!c:/perl/bin/perl.exe

BEGIN {
open STDERR,'>>','error.log';
}

use strict;use warnings;use diagnostics;
use CGI qw/:standard/;
use DBI;

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

my $dbh = DBI->connect("dbi:mysql:database=zz; host=localhost",'root','')
or die "Connecting to MySQL database failed: $DBI::errstr";
print "test";

Program dumps error to file 'error.log'. If it would not work, look at your web server's error log.

Devil0

4:25 am on May 20, 2008 (gmt 0)

10+ Year Member



yay !

finally an error :D

install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: C:/perl/site/lib C:/perl/lib .)

i guess the DBD module isn't installed on my perl ?

chorny

8:49 am on May 20, 2008 (gmt 0)

10+ Year Member



I assume you use ActiveState Perl. Do

ppm install DBD-mysql

from command prompt

Devil0

3:26 pm on May 20, 2008 (gmt 0)

10+ Year Member



i did
install DBD-MYSQL
and
install DB_FILE

and still the same error .. started to hate perl :S i was so excited using it :S

Devil0

3:27 pm on May 20, 2008 (gmt 0)

10+ Year Member



forgot to say :
and did " install Data-Table " too

chorny

5:12 pm on May 20, 2008 (gmt 0)

10+ Year Member


It's DBD-mysql, not DBD-MYSQL. You don't need DB_File. Was install successful? Do you have file C:\Perl\site\lib\DBD\mysql.pm ?
Which version of Perl do you have?

P.S. If you ask for help in case of a very simple problem you should not say that language is bad. I understand that for typical PHP programmer other languages may seem hard. But it is not polite and you may not receive further help.

Devil0

6:33 pm on May 20, 2008 (gmt 0)

10+ Year Member



Yes it was successfully installed .. but I don't have C:\Perl\site\lib\DBD\mysql.pm

I have
C:\Perl\site\lib\DBD\mysql\informationschema.pm

Does it mean anything ?

P.S Iam not a typical PHP programmer and sorry ! Just meant that It's not easy to get used to PERL !