Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grep lines from mysql longblob field

Status
Not open for further replies.

rneve

MIS
Oct 11, 2002
51
EU
Hello,

I have a mysql db with a longblob field. This field contains a logfile. I know how to display this logfile with nl2br.
But what I want is to search for a string (example: failed). I want to display only the lines with the string field in it.

Thanks in advance.
 
number of possible approaches here
1. insert each line into an array, iterate the array and use strpos to search for the string in question.
2. similar but use preg_grep()

and probably a host of others.
 
Thanks for your info.
But I tried to insert each line into an array using the explode command. But everythin is put into the first entry of the array.

I used the following command.

$arrlog=explode(chr(13),$logtxt);

Thanks in advance
 
Code:
//assume file is in $row['logFile']
$logEntries = explode("\n", $row['logFile']);

although i have assumed you are asking how to do this in php (as this is a php forum), you can always use regex in a query to get the answers directly. a pattern like this should work

Code:
(^.*?failed.*?$)


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top