• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can't Uncompress Data Stored to MySQL?

#1
[eluser]Vik[/eluser]
I'm storing a large text file to a MySQL blob field like so:

Code:
$theFile = fopen($thespssDATAfileName, "r+");
$uncompressedDATAFile = addslashes(fread($theFile, filesize($thespssDATAfileName)));
fclose($theFile);

$mysql_query = "UPDATE jobs ";
$mysql_query .= " SET spssDATAfile = (COMPRESS('$uncompressedDATAFile')) ";
$mysql_query .= " WHERE id =  '$theJobID'";
$QueryID = mysql_query($mysql_query);

All appears to go well, and data which appears to be properly compressed is stored in the correct field.

When I try to uncompress it like this:

Code:
$mysql_query = "SELECT UNCOMPRESS(spssDATAfile) FROM jobs ";
$mysql_query .= " WHERE id =  '$theJobID'";
$QueryID = mysql_query($mysql_query);
$theResult = mysql_result($QueryID, 0);

...I get a NULL result.

What am I missing?

Thanks in advance to all for any info.

#2
[eluser]Vik[/eluser]
I got the answer - I had to use a field of type longblob rather than of blob.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.