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 6533029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:04:32+00:00 2026-05-25T10:04:32+00:00

I’m having a very strange problem. My app is causing my server to go

  • 0

I’m having a very strange problem. My app is causing my server to go berserk.

My iOS app uses TFHPPLE to parse data from a php page on my server. It grabs a name from the page, and checks how much time remains for that campaign.

 NSString *URL1 = @"http://alefdev.com/tzedakah/current.php";

NSData *webPage = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat: URL1]]];  

TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:webPage];    
NSArray *elements = [xpathParser search:@"//name"];  

if([elements count] == 0)
{
    NSLog(@"array is empty");

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Error" message:@"Cannot connect to server." 
                                                   delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [alert show];
    [alert release];
    [adupdate invalidate];
    rc.enabled = YES;
    rc.hidden = NO;
}
else{

    TFHppleElement *element = [elements objectAtIndex:0];
    NSString *ttl = [element content];
    NSLog(@"Charity Name:  %@", ttl); 
    todayscharity.text = ttl;


}    

Every 10 seconds, it calls to the server, grabs the info it needs, and puts it into an array. If the array is empty, the timer is invalidated, and a ‘Reconnect’ button appears. The ‘Reconnect’ button restarts the timer.

The timer:

-(void)starttimer{

adupdate = [NSTimer scheduledTimerWithTimeInterval:(10.0) target:self      selector:@selector(updateAd) userInfo:nil repeats:YES];

NSLog(@"starttimer called");}

The restart function

- (IBAction)reconnect:(id)sender
{
[self starttimer];
}

If it fails (empty array) and then restarts, it tries again to grab info from my servers, but cannot. The entire site gives a Internal Server Error (500).

The php script gets the current date

$today = getdate();

$todayfull = $today['year'].$today['mon'].$today['mday'];

Checks the date:

if(($todayfull == 201192)||($todayfull == 201193))

Then echoes some text and runs the countdown function after matching the day.

function countdown($year, $month, $day, $hour, $minute)
{
$the_countdown_date = mktime($hour, $minute, 0, $month, $day, $year, -1);
$today = time();
$difference = $the_countdown_date - $today;
if ($difference < 0) $difference = 0;

$days_left = floor($difference/60/60/24);
$hours_left = floor(($difference - $days_left*60*60*24)/60/60);
$minutes_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60)/60);

if($minutes_left < 1)
{
echo "<ends>Less than 1 minute</ends>";
}
else{
echo "<ends>".$days_left." day ".$hours_left." hours ".$minutes_left." minutes</ends>";
}

Error Logs show:

[Sun Sep  4 14:01:53 2011] [error] [client 184.100.79.143] File does not exist: /home/alefdev2/public_html/error_500.htm
[Sun Sep  4 14:01:53 2011] [error] [client 184.100.79.143] Premature end of script headers: /home/alefdev2/public_html/tzedakah/current.php
[Sun Sep  4 14:01:43 2011] [error] [client 184.100.79.143] File does not exist: /home/alefdev2/public_html/error_500.htm
[Sun Sep  4 14:01:43 2011] [error] [client 184.100.79.143] Premature end of script headers: /home/alefdev2/public_html/tzedakah/current.php
[Sun Sep  4 14:01:43 2011] [error] [client 184.100.79.143] File does not exist: /home/alefdev2/public_html/error_500.htm
[Sun Sep  4 14:01:43 2011] [error] [client 184.100.79.143] Premature end of script headers: /home/alefdev2/public_html/tzedakah/current.php
[Sun Sep  4 14:00:25 2011] [error] [client 184.100.79.143] File does not exist: /home/alefdev2/public_html/error_500.htm

The full php script is:

    <?php
$today = getdate();
$todayfull = $today['year'].$today['mon'].$today['mday'];
echo "Todayfull: $todayfull";

if(($todayfull == 201192)||($todayfull == 201193))
{
echo "<name>The Lone Soldier Center in memory of Michael Levin</name>
<description>Lone Soldier Center desc.</description>    
";

countdown(2011,9,4,0,0);
}
else if(($todayfull == 201194)||($todayfull == 201195)){

echo "<name>Friends of Itamar</name>
<description>Friends of Itamar desc.</description>  
";

countdown(2011,9,6,0,0);
}

else{
echo "Error:  Could not match dates.";
}
?>

<?php
function countdown($year, $month, $day, $hour, $minute)
{
$the_countdown_date = mktime($hour, $minute, 0, $month, $day, $year, -1);
$today = time();

$difference = $the_countdown_date - $today;
if ($difference < 0) $difference = 0;

$days_left = floor($difference/60/60/24);
$hours_left = floor(($difference - $days_left*60*60*24)/60/60);
$minutes_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60)/60);

if($minutes_left < 1)
{
echo "<ends>Less than 1 minute</ends>";
}
else{
echo "<ends>".$days_left." day ".$hours_left." hours ".$minutes_left." minutes</ends>";
}

}
?>

My host (SiteGround) said that I just had too many IMAP processes running, but the site only ever crashes if I try to reconnect thru this app.

  • 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-25T10:04:33+00:00Added an answer on May 25, 2026 at 10:04 am

    There’s two things going on. First, you’re getting too many calls to the server, so I think your timer invalidation isn’t working right. Second, your PHP script isn’t putting out proper header, so you’re getting server errors.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am currently running into a problem where an element is coming back from
We're building an app, our first using Rails 3, and we're having to build
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
i want to parse a xhtml file and display in UITableView. what is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.