Daniel Brown wrote: > On Jan 4, 2008 12:52 PM, afan pasalic <afan@xxxxxxxx> wrote: >> I think you didn't understand my question: I know why the function work >> in 2nd example. My question was why I'm not getting the result in 1st >> example? What am I doing wrong. And, as far as I know, I think it >> doesn't have anything with GLOBALS (register_globals are anyway turned off). > > Also, keep in mind that, in the else{} clause of the first > function, you're not using return; to send back the information. In > my opinion, you shouldn't call a function from within its own > definition because it can cause a loop if the conditions are met and > the else{} clause is reached over and over again. If there is a > situation where get_content(0, 0, $index1); doesn't return any rows, > the function will loop eternally (that is, until PHP gets dizzy and > gives up). > Actually, there were 2 misstakes: <?php function get_InfoContent($instance_id, $form_id, $InfoKey) { $query = mysql_query(" SELECT instance_id, form_id, InfoContent FROM forms_single_info WHERE instance_id=".$instance_id." AND form_id=".$form_id." AND InfoKey='".$InfoKey."' "); if (mysql_num_rows($query) > 0) { $result = mysql_fetch_assoc($query); $InfoContent = $result['InfoContent']; return $InfoContent; } else { $InfoContent = get_InfoContent(0, 0, $InfoKey); return $InfoContent; } } ?> Yes, I ALSO need "return" in "else" statement because when I call the function 2nd time the first return will return to else and then the 2nd return will return to main code. :D And, I called the function 2nd time with get_InfoContent(0, 0, $InfoKey); and it should be $InfoContent = get_InfoContent(0, 0, $InfoKey); :D -afan -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php