![]() |
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; ?> |
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. |
Quote:
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); |
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:
|
See how the insert is done and what kind of encoding is being used.
|
What bigben said... sometimes you'll compress text data and store it in a blob
|
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. |
Quote:
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== |
Quote:
|
Quote:
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. |
Quote:
$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)); |
Quote:
if you want paste the few lines of code you have above that where it shows the fetching of the row, etc... |
Quote:
$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); |
Quote:
Looking at the foreach, it said it was a sub-branch [0], so, try: PHP Code:
|
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. |
try doing a redecode after youve dumped the array
PHP Code:
|
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'])); |
Quote:
thanks everyone for helping me out |
bumping some good expertise
|
For future reference,
Code:
<pre><?php print_r($data); ?></pre> |
All times are GMT -7. The time now is 05:30 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123