Re: explode / implode function call on a field with blob type
| From: | Shahmat Dahlan | Date: | Fri, 05 Aug 2005 05:15:07 +0000 |
| Subject: | Re: explode / implode function call on a field with blob type | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40032@lists.php.net to get a copy of this message | ||
My apologies, I got it all wrong, I simply went and used the split function and join those strings together, and it works.
Shahmat Dahlan wrote:
Correction, my corrected code (mistake in the last line, echo $row->data): $sql_stmt = "SELECT id, data FROM announcements"; $query = mysql_query ($sql_stmt); while ($row = mysql_fetch_object ($query)) { echo $row->id; $tmp = explode (" ", $row->data, 10); #1 $data_stripped = implode (" ", $tmp); #2 ### echo $row->data; #### my mistake, it should be this: echo $data_stripped; } Shahmat Dahlan wrote:I have the following table structure called announcements - id int(6) - data longblob And this is what i did: $sql_stmt = "SELECT id, data FROM announcements"; $query = mysql_query ($sql_stmt); while ($row = mysql_fetch_object ($query)) { echo $row->id; $tmp = explode (" ", $row->data, 10); #1 $data_stripped = implode (" ", $tmp); #2 echo $row->data; } #1 the reason why I had used explode with " " (space character) as the delimeter with the limit set to 10 is because I want to extract only the first 10 words out of the "data". #2 and string those 10 words into a string and display them out instead of getting the intended results (the first 10 words), i get "1111111" is this because my "data" field type is longblob or blog? regards