而循环不按预期循环(while loop not cycling through as expected)
我有一个循环,它运行MySQL查询返回的行并执行命令。
当数据显示在网页上时(在粘贴代码的末尾看到),requested_date(来自$ result_dec查询)正在循环,但memPayout(来自$ emailcompleted查询)不是。 在显示memPayout的地方,它只列出了每个日期的相同数字。
当我在phpmyadmin中运行它时,我看到不同的日期有不同的memPayouts ..所以我知道这里有一个错误。
我很感激帮助。
更新:我已经用我调整过的新代码更新了旧代码。 我试图用最初的foreach包装电子邮件收入查询。 我还删除了不必要的额外bgcolor开关。 我网页上的结果仍然与以前相同。 任何更多的建议真的很感激。
<?php //--------------------- Code for Decline TRANSACTION -------------------------------------- $u_id = $_SESSION['user_ses']['id']; $result_dec = @mysql_query("(select trv.tr_user_id , usr.full_name ,usr.email , usr.paypal , trv.requested_date, trv.requested_status, trv.click_payment_status, trv.tracking_id from tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr where t.id=trv.tracking_id and off.id=t.offer_id and usr.id=trv.tr_user_id and usr.id='1454' and trv.payment_status='pending' and trv.requested_status='declined' group by trv.tr_user_id, trv.requested_date order by trv.requested_date asc ) union all (select trv.tr_user_id , usr.full_name ,usr.email , usr.paypal , trv.click_request_date, trv.requested_status, trv.click_payment_status, trv.tracking_id from tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr where t.id=trv.tracking_id and off.id=t.offer_id and usr.id=trv.tr_user_id and usr.id='1454' and trv.payment_status='pending' and trv.click_payment_status='declined' group by trv.tr_user_id, trv.click_request_date order by trv.requested_date asc ) "); $nr = mysql_num_rows($result_dec); $categories_d = array(); while($row = mysql_fetch_array($result_dec)) { $categories_d[] = $row; } if(count($categories_d)>0) { $counter=0; foreach($categories_d as $index=>$rec) { $counter++; if ($counter % 2 == 0) { $bgcolor = "#FFFFFF"; } else { $bgcolor = "#F5F7D9"; } $userId=$rec['tr_user_id']; $EmailCompletedOffer=@mysql_query("select off.member_amount as memPayout from tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr where t.id=trv.tracking_id and off.id=t.offer_id and off.offer_type='mailchimp' and usr.id=trv.tr_user_id and trv.tr_user_id=$userId and trv.requested_date='".$requested_date."' and trv.payment_status='pending' and trv.total_conversion !=0 and trv.requested_status='declined' "); $rowemailEarn=@mysql_fetch_array($EmailCompletedOffer); $totalEmailEarnAmount1=$rowemailEarn['memPayout']; ?> <div class="datarow_his"> <div class="his_onecol1"><?php echo '$'. $totalEmailEarnAmount1;?> </div> <div class="his_onecol1"> <?php echo "Declined"; ?> </div> <div class="his_onecol2"><?php echo date("M j,Y " ,strtotime($rec['requested_date']));?></div> <!--<div class="his_onecol1"><?php //echo date("M j,Y " ,strtotime($rec['paid_date']));?></div>--> </div> <p><?php echo $totalEmailEarnAmount1?></p> <?php /*} } */ } } ?>
I have a loop that runs through returned rows from a MySQL query and performs commands.
When the data is displayed on the webpage (seen at the end of the pasted code), the requested_date (from the $result_dec query) is cycling through correctly, but the memPayout(from the $emailcompleted query) is not. Where it shows the memPayout it is just listing the same number for each date.
When I run this in phpmyadmin, I see that different dates have different memPayouts..so I know there is a bug here.
I appreciate the help.
UPDATE: I've updated the old code with the new one that I adjusted. I tried to wrap the email earnings query with the original foreach. I also removed the unnecessary extra bgcolor switch. The result on my webpage is still the same as before. Any more advice is really appreciated.
<?php //--------------------- Code for Decline TRANSACTION -------------------------------------- $u_id = $_SESSION['user_ses']['id']; $result_dec = @mysql_query("(select trv.tr_user_id , usr.full_name ,usr.email , usr.paypal , trv.requested_date, trv.requested_status, trv.click_payment_status, trv.tracking_id from tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr where t.id=trv.tracking_id and off.id=t.offer_id and usr.id=trv.tr_user_id and usr.id='1454' and trv.payment_status='pending' and trv.requested_status='declined' group by trv.tr_user_id, trv.requested_date order by trv.requested_date asc ) union all (select trv.tr_user_id , usr.full_name ,usr.email , usr.paypal , trv.click_request_date, trv.requested_status, trv.click_payment_status, trv.tracking_id from tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr where t.id=trv.tracking_id and off.id=t.offer_id and usr.id=trv.tr_user_id and usr.id='1454' and trv.payment_status='pending' and trv.click_payment_status='declined' group by trv.tr_user_id, trv.click_request_date order by trv.requested_date asc ) "); $nr = mysql_num_rows($result_dec); $categories_d = array(); while($row = mysql_fetch_array($result_dec)) { $categories_d[] = $row; } if(count($categories_d)>0) { $counter=0; foreach($categories_d as $index=>$rec) { $counter++; if ($counter % 2 == 0) { $bgcolor = "#FFFFFF"; } else { $bgcolor = "#F5F7D9"; } $userId=$rec['tr_user_id']; $EmailCompletedOffer=@mysql_query("select off.member_amount as memPayout from tbl_trackvalue as trv ,tbl_tracking as t , tbl_offers as off , tblusers as usr where t.id=trv.tracking_id and off.id=t.offer_id and off.offer_type='mailchimp' and usr.id=trv.tr_user_id and trv.tr_user_id=$userId and trv.requested_date='".$requested_date."' and trv.payment_status='pending' and trv.total_conversion !=0 and trv.requested_status='declined' "); $rowemailEarn=@mysql_fetch_array($EmailCompletedOffer); $totalEmailEarnAmount1=$rowemailEarn['memPayout']; ?> <div class="datarow_his"> <div class="his_onecol1"><?php echo '$'. $totalEmailEarnAmount1;?> </div> <div class="his_onecol1"> <?php echo "Declined"; ?> </div> <div class="his_onecol2"><?php echo date("M j,Y " ,strtotime($rec['requested_date']));?></div> <!--<div class="his_onecol1"><?php //echo date("M j,Y " ,strtotime($rec['paid_date']));?></div>--> </div> <p><?php echo $totalEmailEarnAmount1?></p> <?php /*} } */ } } ?>
原文:https://stackoverflow.com/questions/21311663
最满意答案
为什么不使用您的Web服务器作为接口,它创建相应的公钥和私钥,并将其用于加密和解密? 确保您甚至加密将b / w服务器发送到应用程序的密钥加密的方式。
Why not use your web server as a interface, which creates the corresponding public and private key, and uses it for encryption and decryption? Make sure you even encrypt the way the keys which are sent b/w server to application are encrypted.
相关问答
更多-
用Javascript进行Diffie-Hellman密钥交换有时会出错(Diffie-Hellman Key Exchange with Javascript sometimes wrong)[2023-07-08]
3 ^ 54是58149737003040059690390169.它会导致溢出,因此您应该实现模块化指数化 ,因为我不太了解JavaScript,所以我已经编写了应该很容易在javascript中实现的ac代码: int power(int a, int b, int prime){ int result; if(b == 0){ result = 1; }else if(b == 1){ result = a % prime ... -
别。 如果您需要在生产代码中解决此类问题,请让专家来做。 密码学中存在许多微妙的陷阱,你很可能会成为一个收割者。 Don't. If you need to solve this kind of problem in production code, have an expert do it. There are so many subtle pitfalls in cryptography that chances are you will come a cropper.
-
是。 如果 g ^ a mod p = g ^ x mod p 然后 g ^ ab mod p = g ^ xb mod p 尤其是 (g ^ b mod p)^ a mod p =(g ^ b mod p)^ x mod p 因此,出于所有实际目的,您可以假装Alice的私钥是x。 这就是为什么g成为组的生成器很重要的原因,因此没有这样的'兄弟'私钥。 她不知道'原始'a,但她确实知道它是(通常)一小组数字与x不同的o(g)的倍数。 它是哪一个并不重要。 在这种特殊情况下,发生的是g是296而不是592 ...
-
问题是g.pow(secret)是一个真正的,非常非常大的数字。 它比p大得多,并且有大约的secret数字。 如果你将secret增加到普通Diffie-Hellman秘密指数的范围内(与p的数字大约相同),那么你的计算机将没有足够的内存来保存它。 地球上的所有计算机都没有足够的内存来容纳它。 这是一个非常大的数字。 但是g.pow(secret).mod(p) - 你想要的最终答案 - 只有大约和p一样多的数字,所以它是计算机跟踪的易处理数字。 这只是一个太大而无法处理的中间值。 所以你需要利用像这样的 ...
-
Crypto ++网站建议使用最小p为3072位(或ECC实现的256位)来传输128位AES密钥。 您可能希望研究http://www.keylength.com/en/compare/上提供的参考资料,以获取有关比较不同算法之间密钥长度的更多信息。 The Crypto++ website suggests using a minimum p of 3072 bits (or 256 bits for an ECC implementation) to transport a 128 bit AES k ...
-
为什么不使用您的Web服务器作为接口,它创建相应的公钥和私钥,并将其用于加密和解密? 确保您甚至加密将b / w服务器发送到应用程序的密钥加密的方式。 Why not use your web server as a interface, which creates the corresponding public and private key, and uses it for encryption and decryption? Make sure you even encrypt the way th ...
-
你忘了两个模数: >>> 5556302616191343498765890791686005349041729624255239232159744 % 22 16L >>> 793714773254144 % 22 16 You forgot two more modulos: >>> 5556302616191343498765890791686005349041729624255239232159744 % 22 16L >>> 793714773254144 % 22 16
-
您的bcopy更换是错误的。 两者中的第三个参数是长度,另外两个是交换的,所以:#define bcopy(a,b,c)memcpy(b,a,c) Your bcopy replacement is wrong. The third parameter in both is length, the other two are swapped, so do: #define bcopy(a, b, c) memcpy(b, a, c)
-
显而易见的解决方案是使用WCF建立SSL或TLS连接,而不是尝试将其构建到应用程序中。 The obvious solution would be to use WCF to establish an SSL or TLS connection instead of attempting to build that into the application.
-
如何将Diffie-Hellman密钥交换推广到三方或更多方?(How to generalize the Diffie-Hellman key exchange to three or more parties?)[2023-01-05]
它可能比两个复杂一点。 考虑一个有N个人的循环。 每个编号为1,2,3,..., N 。 他们共享相同的P和G. 每个人都有自己的一个号码。 现在每个人都为自己计算G a ,并将结果发送给下一个。 然后每个人计算出值G 1 a ,其中G 1是前一个人给出的值。 重复该过程N次,每个人都有相同的数字G N = G a 1 a 2 ... a N. 伪代码: import G, P from public generate a send pair{pow(G, a, P), 1} to next person ...