Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 08-28-2008, 10:45 AM   #1
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Php/mysql display BLOB field data?

does anyone know how to display the data that is kept in a BLOB field format? I can only find examples that should how to display an image if saved to BLOB format type but nothing on how to display text.

there should be data for two dropdown menu's and two textbox stored in m_addtn field

<?php

$res = mysql_query("SELECT m_addtn FROM s_viz WHERE m_id = '39'");

$result = mysql_fetch_assoc($res);
echo $result;

?>
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 10:45 AM   #2
GigoloShawn
Confirmed User
 
Join Date: Oct 2007
Location: No longer with Star Marketing Group.
Posts: 700
A blob field is usually considered to be binary data.

You're gonna want to escape that.

If you want to display text, you should use TEXT or TINYTEXT and not BLOB for storage.
__________________
I no longer represent TrafficGigolos, please contact Justin or Rebecca with any issues.
GigoloShawn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 11:43 AM   #3
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by GigoloShawn View Post
A blob field is usually considered to be binary data.

You're gonna want to escape that.

If you want to display text, you should use TEXT or TINYTEXT and not BLOB for storage.
unfortunately this script was coded by someone else, i'm trying to clean up all the problem areas that I find. I need to decode the binary unserialize(base64_decode($result)) didnt work... any suggestions? Once I figure out how to decode and retrieve the data I've setup 4 separate fields in which I plan to populate all current user data too and eliminate the BLOB field

this code below just shows me the encoded info, i need to decode it

$res = mysql_query("SELECT m_addtn FROM s_viz WHERE m_id = '39'");
$result = mysql_fetch_array($res);

echo var_dump($result);
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 11:49 AM   #4
GigoloShawn
Confirmed User
 
Join Date: Oct 2007
Location: No longer with Star Marketing Group.
Posts: 700
If it was serialized, it'd likely be base64 encoded afterwards; why it was stored as a blob well, that's kind of dumb. Try print_r($result) to see what's in your array.

Or, you can always:

PHP Code:
foreach ($result as $arg=>$val) {
  echo 
"$arg is $val<br>";

How do you know its base64? Is it terminating with a few =? If not, it may not be base64.
__________________
I no longer represent TrafficGigolos, please contact Justin or Rebecca with any issues.
GigoloShawn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 11:57 AM   #5
BigBen
Confirmed User
 
Join Date: Nov 2004
Location: scv
Posts: 2,299
See how the insert is done and what kind of encoding is being used.
BigBen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 12:47 PM   #6
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
What bigben said... sometimes you'll compress text data and store it in a blob
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 12:56 PM   #7
HomerSimpson
Too lazy to set a custom title
 
HomerSimpson's Avatar
 
Industry Role:
Join Date: Sep 2005
Location: Springfield
Posts: 13,826
what are you saving in database as blob.
If you are saving whole files (images etc...) in database that's bad so try to avoid that any way you can.
__________________
Make a bank with Chaturbate - the best selling webcam program
Ads that can't be block with AdBlockers !!! /// Best paying popup program (Bitcoin payouts) !!!

PHP, MySql, Smarty, CodeIgniter, Laravel, WordPress, NATS... fixing stuff, server migrations & optimizations... My ICQ: 27429884 | Email:
HomerSimpson is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 12:57 PM   #8
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by GigoloShawn View Post
If it was serialized, it'd likely be base64 encoded afterwards; why it was stored as a blob well, that's kind of dumb. Try print_r($result) to see what's in your array.

Or, you can always:

PHP Code:
foreach ($result as $arg=>$val) {
  echo 
"$arg is $val<br>";

How do you know its base64? Is it terminating with a few =? If not, it may not be base64.
for displaying the data in the script it has <? $en['quests'] = unserialize(base64_decode($en['mm_addtn'])); ?>

with print or echo
Array ( [0] => YTo0OntpOjM7czo4OiJCaXNleHVhbCI7aTo2O3M6ODoiSW52b2 x2ZWQiO2k6NDtzOjIxOiJJIEFEREVEIFNPTUUgTkVXIFBJQ1Mi O2k6MTtzOjI5OiJUSEVZIFIgSU4gVEhFIEVYUExJQ0lUUyA0IE 5PVyI7fQ== [m_addtn] => YTo0OntpOjM7czo4OiJCaXNleHVhbCI7aTo2O3M6ODoiSW52b2 x2ZWQiO2k6NDtzOjIxOiJJIEFEREVEIFNPTUUgTkVXIFBJQ1Mi O2k6MTtzOjI5OiJUSEVZIFIgSU4gVEhFIEVYUExJQ0lUUyA0IE 5PVyI7fQ== )

with foreach statement
0 is YTo0OntpOjM7czo4OiJCaXNleHVhbCI7aTo2O3M6ODoiSW52b2 x2ZWQiO2k6NDtzOjIxOiJJIEFEREVEIFNPTUUgTkVXIFBJQ1Mi O2k6MTtzOjI5OiJUSEVZIFIgSU4gVEhFIEVYUExJQ0lUUyA0IE 5PVyI7fQ==
m_addtn is YTo0OntpOjM7czo4OiJCaXNleHVhbCI7aTo2O3M6ODoiSW52b2 x2ZWQiO2k6NDtzOjIxOiJJIEFEREVEIFNPTUUgTkVXIFBJQ1Mi O2k6MTtzOjI5OiJUSEVZIFIgSU4gVEhFIEVYUExJQ0lUUyA0IE 5PVyI7fQ==
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 01:01 PM   #9
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by HomerSimpson View Post
what are you saving in database as blob.
If you are saving whole files (images etc...) in database that's bad so try to avoid that any way you can.
the m_addtn BLOB field is all test/data... the original coder did it that way. I'm just trying to clean things up. In the end I'll insert the text data in 4 separate fields the way it should of been done originally. First task is to decode the data from the BLOB and retrieve it, then insert into m_status, m_ori, m_turn1 and m_turn2
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 01:18 PM   #10
Varius
Confirmed User
 
Industry Role:
Join Date: Jun 2004
Location: New York, NY
Posts: 6,890
Quote:
Originally Posted by BigBen View Post
See how the insert is done and what kind of encoding is being used.
Yup, this would be how to solve it.

Just find what's done to the text before it's inserted, then reverse that when it comes out. A BLOB field itself doesn't do its own encrypting or anything.

On the small chance there is nothing being done to the data before it's put into the database, check for any Triggers in MySQL as there could be one that ON INSERT or ON UPDATE encrypts the value in that field.
__________________
Skype variuscr - Email varius AT gmail
Varius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 01:57 PM   #11
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by Varius View Post
Yup, this would be how to solve it.

Just find what's done to the text before it's inserted, then reverse that when it comes out. A BLOB field itself doesn't do its own encrypting or anything.

On the small chance there is nothing being done to the data before it's put into the database, check for any Triggers in MySQL as there could be one that ON INSERT or ON UPDATE encrypts the value in that field.
this is what it's doing when it processes a update/insert into that field.

$addtn = base64_encode(serialize($_POST['edit_add']));
$q = 'm_addtn="'.$addtn.'"'.$q;

i tried this piece of code (below) but just received a T_String error
print_r unserialize(base64_decode($results));
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 02:04 PM   #12
Varius
Confirmed User
 
Industry Role:
Join Date: Jun 2004
Location: New York, NY
Posts: 6,890
Quote:
Originally Posted by acctman View Post
this is what it's doing when it processes a update/insert into that field.

$addtn = base64_encode(serialize($_POST['edit_add']));
$q = 'm_addtn="'.$addtn.'"'.$q;

i tried this piece of code (below) but just received a T_String error
print_r unserialize(base64_decode($results));
is $results there the array though (recordset returned)? If so that's your error, you need to unserialize(base64-decode()) on the actual string (data of that one field), not the whole returned result (recordset).

if you want paste the few lines of code you have above that where it shows the fetching of the row, etc...
__________________
Skype variuscr - Email varius AT gmail
Varius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 02:44 PM   #13
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by Varius View Post
is $results there the array though (recordset returned)? If so that's your error, you need to unserialize(base64-decode()) on the actual string (data of that one field), not the whole returned result (recordset).

if you want paste the few lines of code you have above that where it shows the fetching of the row, etc...
i just tried the code below, I'm getting a blank page this time around. there is two array 0 and m_addtn

$res = mysql_query("SELECT m_addtn FROM s_viz WHERE m_id = '39'");
$result = mysql_fetch_array($res);

$decode = unserialize(base64_decode($results['m_addtn']));
print_r($decode);
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 03:22 PM   #14
GigoloShawn
Confirmed User
 
Join Date: Oct 2007
Location: No longer with Star Marketing Group.
Posts: 700
Quote:
Originally Posted by acctman View Post
i just tried the code below, I'm getting a blank page this time around. there is two array 0 and m_addtn

$res = mysql_query("SELECT m_addtn FROM s_viz WHERE m_id = '39'");
$result = mysql_fetch_array($res);

$decode = unserialize(base64_decode($results['m_addtn']));
print_r($decode);
Life happened. That is base64, allright.

Looking at the foreach, it said it was a sub-branch [0], so, try:

PHP Code:
$decode unserialize(base64_decode($results['m_addtn']['0']));
print_r($decode); 
__________________
I no longer represent TrafficGigolos, please contact Justin or Rebecca with any issues.
GigoloShawn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 03:29 PM   #15
GigoloShawn
Confirmed User
 
Join Date: Oct 2007
Location: No longer with Star Marketing Group.
Posts: 700
Dammit, I waited too long to edit:

I just saw your very last post.

You're setting $result, and resting $results; otherwise, you're on the right track. No idea why you'd be doing mysql_array("...",MYSQL_BOTH), but, whatever.
__________________
I no longer represent TrafficGigolos, please contact Justin or Rebecca with any issues.
GigoloShawn is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 03:42 PM   #16
jimbona
Confirmed User
 
Join Date: Jan 2007
Posts: 190
try doing a redecode after youve dumped the array

PHP Code:
foreach ($result as $arg=>$val) { 
  echo 
"$arg is ".base64_decode($val)."<br>\n\n"

__________________
Thanks
Paul
Thunder-Ball.net - Member
jimbona is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 05:18 PM   #17
Varius
Confirmed User
 
Industry Role:
Join Date: Jun 2004
Location: New York, NY
Posts: 6,890
as GigoloShawn said above, you are using the variable $results when it is $result heh.

This line should produce what you want:

echo unserialize(base64_decode($result[0][0]));

(feel free to use the field name instead of that second 0 though, to make your code easier to read):

echo unserialize(base64_decode($result[0]['m_addtn']));
__________________
Skype variuscr - Email varius AT gmail
Varius is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-28-2008, 05:21 PM   #18
acctman
Confirmed User
 
Join Date: Oct 2003
Location: Atlanta
Posts: 2,840
Quote:
Originally Posted by GigoloShawn View Post
Dammit, I waited too long to edit:

I just saw your very last post.

You're setting $result, and resting $results; otherwise, you're on the right track. No idea why you'd be doing mysql_array("...",MYSQL_BOTH), but, whatever.
thanks for spotting my error, i tried out MYSQL_BOTH works pretty good.

thanks everyone for helping me out
acctman is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2008, 12:03 AM   #19
d-null
. . .
 
d-null's Avatar
 
Industry Role:
Join Date: Apr 2007
Location: NY
Posts: 13,724
bumping some good expertise
__________________

__________________

Looking for a custom TUBE SCRIPT that supports massive traffic, load balancing, billing support, and h264 encoding? Hit up Konrad!
Looking for designs for your websites or custom tubesite design? Hit up Zuzana Designs
Check out the #1 WordPress SEO Plugin: CyberSEO Suite
d-null is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 08-29-2008, 12:44 AM   #20
mrkris
Confirmed User
 
Join Date: May 2005
Posts: 2,737
For future reference,

Code:
<pre><?php print_r($data); ?></pre>
Having it aligned in browser will help you follow nested data structures much easier.
__________________

PHP-MySQL-Rails | ICQ: 342500546
mrkris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.