Re: explode / implode function call on a field with blob type
| From: | Shahmat Dahlan | Date: | Thu, 04 Aug 2005 08:59:53 +0000 |
| Subject: | Re: explode / implode function call on a field with blob type | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-40030@lists.php.net to get a copy of this message | ||
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