Current location: Hot Scripts Forums » Programming Languages » PHP » [SOLVED] base64 decoding prob


[SOLVED] base64 decoding prob

Reply
  #1 (permalink)  
Old 05-18-08, 07:51 PM
kiko08 kiko08 is offline
Newbie Coder
 
Join Date: Oct 2006
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
[SOLVED] base64 decoding prob

hello,
i have a problem with base64 decoding with the "<br>" tag. heres what happen, it shows only the first 2 "<br>" tags.

sample:
base64 =
HTML Code:
dGVzdDxicj50ZXN0PGJyPnRlc3Q8YnI+dGVzdDxicj50ZXN0PGJyPnRlc3Q8YnI+
actual text =
HTML Code:
test<br>test<br>test<br>test<br>test<br>test<br>
it only displays
test
test
test

and if i look on the source code it has this code:

HTML Code:
test<br>test<br>test<br\\\
can someone pls help me?
thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 05-18-08, 11:48 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
mmm im not getting anything wrong with it:
PHP Code:

$string 'test<br>test<br>test<br>test<br>test<br>test<br>' ;

$encode base64_encode($string) ;     echo $encode.'<br>' ;
echo 
base64_decode($encode) ; 
Try encode some different test

Lex
__________________
01010000 01001000 01010000
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 05-19-08, 12:59 AM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
Same, I've just tested it and it comes out fine
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 05-19-08, 03:47 AM
kiko08 kiko08 is offline
Newbie Coder
 
Join Date: Oct 2006
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
thanks for the help.
ive tried your code and its working.
but when i tried it the way ill will use it, its still has the problem i mentioned above.

heres what i want to do
1. the base64 value is a string query. i mean its part of the url.
2. i only need to decode the ecripted base64 string.

thanks again. hope you can help me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 05-19-08, 03:52 AM
Jay6390's Avatar
Jay6390 Jay6390 is offline
Code Master
 
Join Date: Apr 2007
Location: United Kingdom
Posts: 1,330
Thanks: 0
Thanked 0 Times in 0 Posts
I'd suggest you echo out the string before the decode, and check that all of it is actually being sent, since it seems to be chopping off a certain amount of the string
__________________
Useful Tutorials
[ PHP Video-1-2-3 ] [ MySQL 1-2-3 ]
For any php function reference type

www.php.net/FunctionName
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 05-19-08, 03:53 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
since there's a + sign at the end of the base64 encoded string, it might cause problems in a browser, as a + sign can also be used to replace spaces. For instance, placing this url http://mysite.com/mypage?var=Hello World might end up like this http://mysite.com/mypage?var=Hello+World So whenever you grab the value of the $_GET['var'] variable, php might convert the plus sign to a space character.

To prevent this, use the functions urlencode and urldecode
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 05-19-08, 03:54 AM
kiko08 kiko08 is offline
Newbie Coder
 
Join Date: Oct 2006
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
oh i found something.
this is the base64 ecoded value
dGVzdDxicj50ZXN0PGJyPnRlc3Q8YnI+dGVzdDxicj50ZXN0PGJyPnRlc3Q8YnI+

and heres the value when i echoed the string thats comming from the string query. theres no "+" signs.
dGVzdDxicj50ZXN0PGJyPnRlc3Q8YnI dGVzdDxicj50ZXN0PGJyPnRlc3Q8YnI
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 05-19-08, 03:56 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
read my post
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 05-19-08, 04:00 AM
kiko08 kiko08 is offline
Newbie Coder
 
Join Date: Oct 2006
Posts: 88
Thanks: 0
Thanked 0 Times in 0 Posts
@phpdoctor, jay6390 and unrealed
thanks for the help.

i tried unrealeds suggestion and it work!
thanks again.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Decoding an XML base64 encoded data Archu ASP.NET 1 03-10-08 01:27 PM
focus prob in ascx daivagna ASP.NET 3 12-18-07 09:45 AM
prob. file download box daivagna ASP.NET 6 02-28-07 02:02 AM
Echo from DB prob // Image Visble Prob bigredkacy PHP 1 09-04-06 05:02 AM
MIME decoding maxpayne PHP 1 08-17-05 06:30 AM


All times are GMT -5. The time now is 03:26 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.