ios的vn服务器未响应,iOS应用程序导致内部服务器错误

我有一个很奇怪的问题。我的应用程序正在导致我的服务器狂暴。iOS应用程序导致内部服务器错误

我的iOS应用程序使用TFHPPLE解析来自服务器上的PHP页面的数据。它从页面抓取一个名称,并检查该广告系列剩余多少时间。

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;

}

每隔10秒钟,它会调用服务器,获取所需信息并将其放入数组中。如果数组为空,则定时器失效,并出现“重新连接”按钮。 '重新连接'按钮重新启动计时器。

定时器:

-(void)starttimer{

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

NSLog(@"starttimer called");}

重启功能

- (IBAction)reconnect:(id)sender

{

[self starttimer];

}

如果失败(空数组),然后重新启动,再次试图从我的服务器抓取信息,但不能。整个站点发出内部服务器错误(500)。

PHP脚本获取当前日期

$today = getdate();

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

检查日期:

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

然后呼应一些文本和天吻合后运行倒计时功能。

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 "Less than 1 minute";

}

else{

echo "".$days_left." day ".$hours_left." hours ".$minutes_left." minutes";

}

错误日志显示:

[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

完整的PHP脚本是:

$today = getdate();

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

echo "Todayfull: $todayfull";

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

{

echo "The Lone Soldier Center in memory of Michael Levin

Lone Soldier Center desc.

";

countdown(2011,9,4,0,0);

}

else if(($todayfull == 201194)||($todayfull == 201195)){

echo "Friends of Itamar

Friends of Itamar desc.

";

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

}

else{

echo "Error: Could not match dates.";

}

?>

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 "Less than 1 minute";

}

else{

echo "".$days_left." day ".$hours_left." hours ".$minutes_left." minutes";

}

}

?>

我的主机(SiteGround)说,我只是有太多的IMAP进程在运行,但该网站只有当我尝试重新连接这个应用程序时才会崩溃。

2011-09-04

bfost

+0

服务器日志文件在获得500时会说什么?另外,你可以发布完整的服务器端代码吗? –

+0

我已经添加了日志条目和php脚本。 –

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值