Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

PHP and MySQL blobs

Name: Anonymous 2007-08-23 14:19 ID:iDy72R64

hey /prog/, I'm trying to update a mysql table, here is the column that is giving me issues:

document_content - mediumblob


How can I take a plain ol' string from PHP and update this column with a string? The column keeps updating to 0 and Google hasn't been much help.



Name: Anonymous 2007-08-23 14:23 ID:ii69gktD


document_content - moeblob


fixed

Name: Anonymous 2007-08-23 14:25 ID:Heaven

I'm going to take a wild guess here and claim PEBCAK.

Name: Anonymous 2007-08-23 14:39 ID:iDy72R64

>>3
There must be some way though, and I can't really do much about changing the table's definition since I didn't install this and our software would fail hard since this column is used to store other data than just strings.

Name: Anonymous 2007-08-23 14:58 ID:9KHi3E4g

More information please.

Name: Anonymous 2007-08-23 15:30 ID:zgbfHWd0

BLOBZ are for binariz, one does not simply read into BLOB.

Name: Anonymous 2007-08-23 17:16 ID:iDy72R64

>>6
Well, I understand that part, but how does one go from ascii to binary? I found a user function on the PHP site called str2bin(), but it's output of 1s and 0s doesn't transmit as  binary data so the column still comes up empty.


<?php
$string = "<enterpriseXMLtoSaveAsBlob>";
$string = "somestuff";
$string = "</enterpriseXMLtoSaveAsBlob>";

/*
mysql> explain stupidTable; +----------------------+--------------+
| Field                | Type         |
+----------------------+--------------+
| id                   | int(11)      |
| document_name        | varchar(255) |
| document_content     | mediumblob   |
+----------------------+--------------+
*/

$query = 'update stupidTable set ';
$query.= 'document_content="' . $string . '" ';
$query.= 'where id=' . $id;

$res = mysql_query( $query );
/*
The above returns TRUE (success), however the document_content becomes 0 instead of the XML. How do I string-to-binary?
*/

?>

Name: Anonymous 2007-08-23 17:23 ID:9KHi3E4g

Could it be that you're using double quotes around your string rather than single quotes. Maybe this would work?

$query.= 'document_content=''' . $string . ''' ';

Name: Anonymous 2007-08-23 17:23 ID:Heaven


FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTSFUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
v
v
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTSFUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS

FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTSFUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS
FUCK OFF TAKE YOUR FAIL TECHNOLOGIES WITH YOU FAGGOTS

Name: Anonymous 2007-08-23 17:31 ID:Heaven

>>9
------------------------------
WARNING! MENTAL ILLNESS ALERT!
------------------------------

Name: Anonymous 2007-08-23 17:45 ID:iDy72R64

>>8
Extreme quoting, but no - the content I'm sending looks like this:
<someXmlTag name=\'foo\' param1=\'bar\'> and I have it actually like this anyways:

$query .= 'set document_content="' . $newXML . '" and ';


I've tried the pack() command to send it as unsigned char, (pack('c', $newXML)), but no luck. It uploads as binary data to the blob, but the data doesn't translate back properly and so it fails, though I should likely unpack, no? Even so, most of the pre-existing data isn't pack'd and looks like straight strings in the DB table, but then updating with strings fails.

Name: Anonymous 2007-08-23 18:10 ID:zgbfHWd0

$string  = "<enterpriseXMLtoSaveAsBlob>";
$string .= "somestuff";
$string .= "</enterpriseXMLtoSaveAsBlob>";

$query  = "UPDATE stupidTable SET ";
$query .= "document_content = '{$string}' ";
$query .= "WHERE id = '{$id}'";

Name: bawls 2007-08-23 18:53 ID:tVeBbWJc

bawls

Name: Anonymous 2007-08-23 19:00 ID:Iz+LI3E8

>>12
Don't do that!

Name: Anonymous 2007-08-24 0:08 ID:8benTqs/

>>14
why not?

Name: Anonymous 2007-08-24 2:59 ID:Heaven

>>14
$string  = "<enterpriseXMLtoSaveAsBlob>";
$string .= "omg hax}';DELETE FROM stupidTable;SELECT from stupidTable";
$string .= "</enterpriseXMLtoSaveAsBlob>";

Name: Anonymous 2007-08-24 7:31 ID:EMWrABQP

>>16
I'm sure his enterprise grade software has some mysql_real_fuck_yeah_escape_string(). That's not the problem here.

Name: Anonymous 2007-08-24 7:54 ID:bll/UrUT

This thread delivers

Name: Anonymous 2007-08-24 13:51 ID:8benTqs/

But not for OP

Name: Anonymous 2007-08-24 17:22 ID:Heaven

ENTERPRISESOLUTION

Name: Anonymous 2011-03-13 15:19

dun dun
dun dun
dun dun
dun dun
I AM A DATABASE

Name: Anonymous 2011-03-13 19:56

use lisp

Name: Anonymous 2013-09-01 13:42



              _,,.. -─- 、.,_               /
          _r-<´   `Y´ ̄Y´ ̄ヽ、,          /  よ
        .,. '"7、  ,ゝ-‐''"´`ヾ;´ー- 、/´`ヽ,_       ,'   く
       ./ 「´ ,>'"           ´`ヽ/ !     i   .言
       ;' ./´ V´  /  / ,'  ,  !  !  `ヽ7、   |     う
      ;'  `ヽ,'  ./ /メ、/ /! /  /! i   ', ヾ!    !   わ
      !   i   ,'  ;'‐ァ-'、, ' //! /_」 i  i `>   !   ね
      ',  ノ_,,..イレイ i,ソ iヽ´  レ' _」,、ハ ! ,.ゝ  ∠
      ノ ´ ';  ハ  ゝ-'      '!ノ!.!7 ! V      `ヽ、.,________
    ,.イノ   !   !メ)''"      ,  `'’ ! ハヽ(        __________
   (,.イ   ノ ノ(,ハ u   r- 、.,_   "',!ヽ( `    ,. '"´
     )、 __/´ ̄7ー、! !,ゝ、  、___ソ  ,.イ /i '.,   ____/    見
     rソ`ァ'"´ `ヽ、_,)ンi> ,、.,_,,.. イ‐ァ!ソ!ハ ノ   \     た
     iヽ/      ヽ,ヘ)`ヽ、_,.イ_i7 iメ)7´(      |    事
     Y   ,'      }>Yく{_/ム_」';ヽ(X!ヽ.      |    無
     /agic       V´ハ:::/ ハ i:::}>く{       !    い
    ノ         ';:::::::く__/__」┘::ヽ.ヽ.        !    く
   くr-、,_     !  ,ゝ::::::::::::::::';::::::::::::::':, ':,      |    せ
     '/  `"'ーァ、,」_,.イ::、:::::::::::::::::/i::::::::::::::::i  ',     ',     に
    / _,,...,,_/´ ヽ;ヽノ:::::`:::::::::::::::::::::::::::::;:イ  ,ゝ     ヽ、.,___________
   i     `"''ー'- 、;::::::::::::::::::::::::::::::::::::::!-‐i
   ヽ、.,_  ____    `ヽ;:::::::::::::::::::::::::::::::',  ',
       ̄r‐'",ゝ ,   i>,、:;____」;;:: -‐ヘ  ヽ、

Name: Anonymous 2013-09-01 15:13



          ト、   _,,.. -──- 、.,_   ト、
         / '"´ _,,.. -─- ..,,_  `ヽ/ .}
         /  ,. '"´  /´     7⌒'-、 `ヽ
      , '   /     ;    ト 、 |__,ノ、 ,ハ
      ;'  , '   /,  i      ! _ヽ   、\ |   さっきから脳内で繰り返している
      ,l  ./   /-./ト/|    ,ム __  ,ハ   ; ヽ、.,_    クン・カクンカって
    /  '   ; /_」_八   / ァ'lフてlメ|   |  |  `ヽ    どういう意味ですか?
  <.,_   |   |ィ'´hフ「} \/   ゝ--゚'.!   ! .八    }
      `ソ.八  |! 、ゝ'"´   ,    xx./  /   \ /
    ∠.,,_ イ\ 、xx           ∠ イ    ノ⌒ )
      ノ  _,>ヽ     lr ̄`ヽ   /ソ  (  /
       '´ ̄l「  人     、   ノ  //    Y
        八   ノ> 、,    , イ/    ノ}ノ 、
       /   )_, イ  _,,..ノ`l ァ'´  ト、.,,_r 、(    \
      ;     レ'´ _,,.r' |   ./  \>ー‐- 、   ;
      {     _,,.. -l´{!  \ /     //    \ }
      人  /´   ヽr\;'⌒'v'⌒';  /7      ∨
     '  `7     |  ヽr\  /イr┘!         ト 、
      {   ;    ヽ;   / ̄`ヽ!「    |./      |  ';
      、  |     {  /  二ヽ7´ヽ,  ,L.,_      |_.ノ
      \|/    ,r‐'7   r‐ァ'   Y´::::::::`ヽ.   ;
       r'    / /{   _ノゝ、  _,ノ ̄\く()}   ム

Don't change these.
Name: Email:
Entire Thread Thread List