Page 1 of 1

Search in string ?

Posted: Mon Mar 27, 2006 4:22 am
by NeoNmaN
Pimptastic | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Hallo all i hav this code

Code: Select all

// Smider søge ord og type af søgemaskinen ind.
$SogeFelt = $_GET[Ref];
function GetSearchInfo($SearchName,$Search,$Query,$String) {
	if (ereg($Search, $String)) {
		
		
		preg_match($Query, $String, $match);
		
		mysql_query("INSERT INTO search_words SET words = '". $String ."'");
		
		if ($match[1] != "") {
			mysql_query("INSERT INTO search_words SET words = '". $match[1] ."', search_engine = '". $SearchName ."'");
		}
	}
}

GetSearchInfo('Jubii'	,'search.jubii.dk'	,'/\query\=(.+?)\&/'	,$SogeFelt);
GetSearchInfo('Yahoo'	,'search.yahoo.com'	,'/p\=(.+?)\&/'		,$SogeFelt);
GetSearchInfo('MSN'		,'search.msn'		,'/\q\=(.+?)\&/'		,$SogeFelt);
GetSearchInfo('Eniro'	,'www.eniro'		,'/\q\=(.+?)\&/'		,$SogeFelt);
GetSearchInfo('Google'	,'www.google'		,'/\q\=(.+?)\&/'		,$SogeFelt);
bot i cant search in the string bot all work bot not my "search.yahoo.com" string soe i hob i can be help here. i cant find help here ind denmark to it... soe i really hob i can be helpet here.


soe now ist my Questing

-------------------

Why work search.yahoo.com not ?
string ist search on: http://dk.search.yahoo.com/search?fr=fp ... meta=vc%3D

soe how can i get: p=pagedesign all work bot not yahoo.com search string.

-------------------


How can i search in the string if the "query" is last ind one string...
my string is: http://search.msn.dk/results.aspx?FORM= ... pagedesign

soe fx. q=pagedesign is the queary i wont get it.. i can't use $_GET[] becures ist variable andt not "HTTP GET" i use.


Pimptastic | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Mon Mar 27, 2006 4:38 am
by jmut
I read this topic 5times. Really hard stuff to read.
Just a clue ....maybe you want to use

Code: Select all

parse_url()
//for better performance on matching string in string might consider using
strstr()
P.S. Try to simplify the problem and we might be able help ;)

Posted: Mon Mar 27, 2006 4:43 am
by NeoNmaN
I try to write soe good english i now can :) im not soe good to english bot i try to lern it better.

and i can get you to explaen whot the commands to ?

Posted: Mon Mar 27, 2006 5:07 am
by NeoNmaN
Pimptastic | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


Thx ist working

Code: Select all

<?
$URL = "http://search.msn.dk/results.aspx?FORM=MSNH&CP=1252&q=pagedesign";
#$URL = "http://search.msn.dk/results.aspx?q=pagedesign&srch_type=0&FORM=QBRE";

function http_explode($stringInput) {
	if (! is_string($stringInput))
		return false;
	
	$arr_query=NULL;
	$args=explode('&',$stringInput);
	
	foreach($args as $arg) {
		$parts=explode('=',$arg);
		$arr_query[$parts[0]]=$parts[1];
	}
	
	return $arr_query;
} 
  
$URL2 = parse_url($URL);
$HTTP = http_explode($URL2[query]);

echo '<pre>';
print_r($URL2);
echo '</pre>';
echo '<hr />';
echo '<pre>';
print_r(http_explode($URL2[query]));
echo '</pre>';
echo '<hr />';
echo '<pre>';
print_r($HTTP[q]);
echo '</pre>';
?>
my final code i testing :)


Pimptastic | Please use

Code: Select all

and

Code: Select all

tags where appropriate when posting code. Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Mon Mar 27, 2006 5:14 am
by jmut
Just have in mind

Code: Select all

parse_url()
/*
This function is not meant to validate the given URL, it only breaks it up into the above listed parts.
On seriously malformed URLs, parse_url() may return FALSE and emit a E_WARNING.
*/

Posted: Mon Mar 27, 2006 5:33 am
by NeoNmaN
Year really thx :)