逻辑仅运行一次 [英] Logic Runs Once Only

查看:76
本文介绍了逻辑仅运行一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码有效,但是只有一次,当它返回FAIL时,即使应该返回,也不会再次失败.它确实会继续运行返回ICMP,TCP和UDP IP的第一部分.是不是MySQL连接断开了?任何帮助表示赞赏.谢谢!

This code works but only once, when it returns FAIL it doesn''t return fail again even though it should, however; it does keep running the first part returning ICMP, TCP and UDP IP''s....Is it that the MySQL connection is broken? Any help appreciated. Thanks!

if ( bShowTCP )
{
printf("\n -------------------- // -------------------- ");
printf("\n TCP Header:");
              				
int *addressValue = new int();
char *address = LIP; 
inet_pton(AF_INET, address, addressValue);
	if (ip_header->source_ip == *addressValue)
		{
		printf("\n   Source      IP: %s", "0.0.0.0");
		printf("\n   Destination IP: %s", ipDest);
		}
		else
		{
		printf("\n   Source      IP: %s", ipSrc);
		printf("\n   Destination IP: %s", ipDest);
		if (mysql_real_connect(conn,"urlock.db.5513143.hostedresource.com","VendorCheck","Reader1234","urlock",0,NULL,0) !=0)
{
(mysql_query(conn,"SELECT COUNT(*) FROM tblURLIP WHERE IP = inet_aton(''ipSrc'') And IPStatus = ''1'' And IPMax = ''0''"));
	my_ulonglong i = 0;
	res_set = mysql_store_result(conn);
	my_ulonglong numrows = mysql_num_rows(res_set);
	LEGIT = mysql_fetch_row(res_set);
		if (atoi(LEGIT[i]) == 1)
			{
			printf("\n PASS: %s\n",LEGIT[i]);
			//Insert tblIPAccess
			(mysql_query(conn,"INSERT INTO tblIPAccess (IP , Dwnload)  VALUES(inet_aton(''ipSrc''), ''1'')"));
		//Get Number Of Records
(mysql_query(conn,"SELECT COUNT(*) FROM tblURLAccess WHERE IP = inet_aton(''ipSrc'') And Dwnload = ''1''"));
		my_ulonglong g = 0;
		res_set = mysql_store_result(conn);
		my_ulonglong numrows = mysql_num_rows(res_set);
		TTL = mysql_fetch_row(res_set);
		//Get Quota
(mysql_query(conn,"SELECT (IPQuota) FROM tblURLIP WHERE IP = inet_aton(''ipSrc'') And IPStatus = ''1''"));
        	my_ulonglong h = 0;
		res_set = mysql_store_result(conn);
		MX = mysql_fetch_row(res_set);
		//If Quota and Records Match Set IPMax to 1 or True otherwise do     nothing
		if ((atoi(TTL[g])) < (atoi(MX[h])))
		{
		(mysql_query(conn,"UPDATE tblURLIP SET IPMax ''1'' WHERE IP = inet_aton(''ipSrc'')"));
		//printf("Maxed! %s\n");
		mysql_close(conn);
		}
		}
		else
		{
		printf("\n FAIL: %s\n",LEGIT[i]);
		}
		//system("\n  PAUSE");
			}			   
			}
			}
          break;

推荐答案

在我看来,您关闭连接的代码在一个条件之内.那时我怀疑您没有关闭连接.也许如果您在调试器中逐步执行代码,就可以看到失败的地方?
It looks to me like your code to close the connection is inside a condition. I suspect then that you''re not closing your connection. Perhaps if you step through the code in a debugger, you can see where it fails ?


这篇关于逻辑仅运行一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆