Function Return (recursion error?)

view full story

http://www.daniweb.com – Ok - I've got an easy one for you all on this Friday. I know the answer is staring me in the face, but I can't seem to figure it out. The problem is that the following function does not return a value for me. However, if I insert a print statement before the 'return $new_id' line, the correct id is printed to the screen. Also, if I provide an oID that returns 0 on the first try, the function returns a value. Otherwise, it loops as expected, exits at the return statement, but no ID is returned. No infinite loop is created and no other errors can be found. function GetRefundOrderNumber($oID,$try=0) {     $new_id = $oID ."-R";         if ($try != 0)     {         $new_id .= $try;     }         $query = "SELECT orders_id FROM orders WHERE refund_orders_id='$new_id'";     $query_res = mysql_query($query);         if (mysql_num_rows($query_res) === 0)     {         return $new_id;     }     else     {         $try++;         GetRefundOrderNumber($oID,$try);     } } $id = GetRefundOrderNumber(163308); print "ID = $id"; Any suggestions would be appreciated. (General)