Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4590610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T22:16:35+00:00 2026-05-21T22:16:35+00:00

1st i have to say that i am not php professional and this is

  • 0

1st i have to say that i am not php professional and this is my 1st time to use return().

so here is the code.
i need to return false and the number of minutes left from the function.

if(!checkIpn())
    $err[]='you need to wait'.$nresting.'minutes before you send another request';
function checkIpn()
{
    $useripe = 0;  
 if ( isset($_SERVER["REMOTE_ADDR"]) )    {     $useripe = $_SERVER["REMOTE_ADDR"] ; } 
 else if ( isset($_SERVER["HTTP_X_FORWARDED_FOR"]) )    {     $useripe =  $_SERVER["HTTP_X_FORWARDED_FOR"] ; } 
 else if ( isset($_SERVER["HTTP_CLIENT_IP"]) )    {     $useripe =  $_SERVER["HTTP_CLIENT_IP"] ; }


 $query  = "SELECT * FROM table WHERE ip = '$useripe' AND status = 'pending' ORDER BY id ASC"; 
 $result = mysql_query($query) or die(mysql_error());   
 $num_rows = mysql_num_rows($result);  

  if ( $num_rows > 0 ) 
 {  
    $str_today = date("Y-m-d H:i:s"); 
    $i=1; 
    while($row = mysql_fetch_assoc($result)) 
        { 
            $str_start = $row['date'];    
            $str_start = strtotime($str_start);  
            $str_end = strtotime($str_today);    
            $nseconds = $str_end - $str_start;   
            $nminutes = round($nseconds / 60);    
                    if ( $nminutes > 120 ) 
                            { return true; } 
                    else    { 
                            $nresting = 120 - $nminutes;
                            return false; }  
            $i++; 
        } 
 } 
 else { return true; }  

based on Tadeck answer below.i did it like this:

$result = checkIpn();
if($result[0]==false)
    $err[]='you need to wait '.$result[1].' minutes before you send another request';

thank you Tadeck.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T22:16:35+00:00Added an answer on May 21, 2026 at 10:16 pm

    If you want to return two different variables using single call, you can use something like:

    return array(true, 0);
    

    or

    return array(true);
    

    in first case (when returning success) and

    return array(false, $minutes);
    

    in second case (returning failure).

    Then you can check it that way:

    $result = checkIpn();
    
    if ($result[0]) {
        echo 'Success.';
    } else {
        echo 'Failure. Minutes to wait: '.$result[1];
    }
    

    I hope this helps.

    EDIT:

    If I understand you correctly, you return true or the number of minutes > 0 (larger than zero). Thus you can use such return in case of success:

    return true;
    

    and this in case of failure:

    return $minutes;
    

    Then you will be able to use it in the code in the following way:

    $result = checkIpn();
    
    if ($result === true) {
        echo 'Success';
    } else {
        echo 'Failure. Minutes to wait: '.$result;
    }
    

    And I would like to advise you to properly document such function, so that no one is surprised when it returns integer instead of boolean 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

1st I have to say I know nothing bout php. I was actually doing
Lets say you have strings of this format. January 11th, 111 November 1st, 1101
I have 1st popup, and this 1st popup opens 2nd popup Code: <view-state id=paneMaintenance
I have 3 arrays like this: 1st Array ( [0695] => Array ( [loan_number]
I have an application that is good from September 1st of the current year,
I'm going to re-ask this question in a slightly different way. Say I have
I am not sure if I have named this question right but the explanation
Say I have the string 1 December 2012, 8:00:00 I know that it is
i have this file that i want to open, a csv file, and i
I have an autocomplete implementation that is based mostly on this tutorial: http://viralpatel.net/blogs/tutorial-create-autocomplete-feature-with-java-jsp-jquery However

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.