Jump to content

script executes the 'IF' -AND- the 'ELSE'!! how can that happend?


itay

Recommended Posts

when I run my script. it goes through the IF statement, and executes what's inside the brackets. then it proceed to the ELSE and execute it as well!!

 

how can it be?

 

 

this is the snippet from my code:

 

if (preg_match_all("/$regexp/siU", $f04_extrapages_a, $matches, PREG_SET_ORDER)) {
	echo '<font color="gold">if!</font>';
	foreach($matches as $match) { 
		# $match[2] = link address 
		$seqlink=$match[2];
	}		    
	if (preg_match('/next_button_inactive/',$f04_extrapages_a)) {
		if ($log==1) echo date('h:i:s') . "End of results.<br />";
		return '1';
	}
	else {
		$seqlink="http://www.411.com".$seqlink;
		if ($log==1) echo date('h:i:s') . "sequel link: $seqlink<br />";    
		return $seqlink;
	}
}
else {
	echo '<font color="gold">else!</font>';
	if ($log==1) echo date('h:i:s') . "<strong><font color='red'>F**K! <I>preg_match_all(\"/$regexp/siU\", $f04_extrapages_a, $matches, PREG_SET_ORDER)</i> HAS FAILED!</font></strong>";
	return '0';
}

 

here is a snippet from the output I get:

 

if!07:17:44sequel link: http://www.411.com/business?key=hair+salon&page=2&t=0bf2bc88f69d4364883a782fe9dfd06c&where=11103

else!07:17:44F**K! preg_match_all("/]*href=("??)([^" >]*?)\1[^>]*>(.*)<\/a>/siU", , Array, PREG_SET_ORDER) HAS FAILED!07:17:44:

Link to comment
Share on other sites

i've disabled the RETURN command at the end of inner ELSE, and it fixed the issue! weird...

 

//			return $seqlink;

 

but still no good, because I need that RETURN.

 

(this code snippet is a part of a function)

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.