Re: explode / implode function call on a field with blob type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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





-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux