tadman Posted May 5, 2008 Posted May 5, 2008 Anybody... I have added some javascript to my EDIT_ORDERS.PHP. This javascript makes certain words bold when the page is displayed - which it does successfully. However when I click on the UPDATE button the page throws up the following error: Warning: Invalid argument supplied for foreach() in /home/apadevco/public_html/compriganet/admin/edit_orders.php on line 408 Warning: Invalid argument supplied for foreach() in /home/apadevco/public_html/compriganet/admin/edit_orders.php on line 520 Warning: Invalid argument supplied for foreach() in /home/apadevco/public_html/compriganet/admin/edit_orders.php on line 536 Warning: Invalid argument supplied for foreach() in /home/apadevco/public_html/compriganet/admin/edit_orders.php on line 546 Warning: Cannot modify header information - headers already sent by (output started at /home/apadevco/public_html/compriganet/admin/edit_orders.php:408) in /home/apadevco/public_html/compriganet/admin/includes/functions/general.php on line 57 If I remove the javascript the problem goes away. Here is the the Javascript (which is in the <head> section with the other JS): <script language="javascript"><!--function bolidfy(container, str){ container.innerHTML = container.innerHTML.split(str).join('<B>'+str+'</B>'); } window.onload = function(){ bolidfy(document.getElementById('bebold'), 'paper'); bolidfy(document.getElementById('bebold'), 'design'); } //--></script> I have been through the files and removed all white spaces before <? and after ?>, but alas, it hasn't worked. tadman.
♥geoffreywalton Posted May 5, 2008 Posted May 5, 2008 And what is on line 408, 520 ..... ? Need help installing add ons/contributions, cleaning a hacked site or a bespoke development, check my profile Virus Threat Scanner My Contributions Basic install answers. Click here for Contributions / Add Ons. UK your site. Site Move. Basic design info. For links mentioned in old answers that are no longer here follow this link Useful Threads. If this post was useful, click the Like This button over there ======>>>>>.
tadman Posted May 6, 2008 Author Posted May 6, 2008 And what is on line 408, 520 ..... ? On 408 (in red) : $ot_class = ''; foreach($update_totals as $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); On 520 (in red): // Shipping Tax foreach($update_totals as $total_index => $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot");
arietis Posted May 7, 2008 Posted May 7, 2008 On 408 (in red) : $ot_class = ''; foreach($update_totals as $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); On 520 (in red): // Shipping Tax foreach($update_totals as $total_index => $total_details) { extract($total_details,EXTR_PREFIX_ALL,"ot"); i don't think it has anything to do with the javascript, since the error you're seeing is a php error - this occurs before the page is downloaded to the browser and the javascript has a chance to run. where and how is $update_totals declared? it may not be initialized, or initialized as an array, which is probably the problem. the 'Cannot modify header information' error is happening because of the other errors. once you fix the problems on 408, 520, 536 and 546 this one should go away.
tadman Posted May 15, 2008 Author Posted May 15, 2008 i don't think it has anything to do with the javascript, since the error you're seeing is a php error - this occurs before the page is downloaded to the browser and the javascript has a chance to run. where and how is $update_totals declared? it may not be initialized, or initialized as an array, which is probably the problem. the 'Cannot modify header information' error is happening because of the other errors. once you fix the problems on 408, 520, 536 and 546 this one should go away. Thanks for your time Dave. Here is how the $update_totals is declared before line 408: if (isset($_GET['update_products'])) { $update_products = $_GET['update_products'] ; }else if (isset($_POST['update_products'])){ $update_products = $_POST['update_products'] ; } else { $update_products = '' ; } So the variable is assigned a value or initialised beforehand. Seems OK to me. The only thing I can think of is because the HTML page is being added to/changed by js, it somehow adds white space and therefore the headers problem.
arietis Posted May 16, 2008 Posted May 16, 2008 the last case in the if test is: $update_products = ''; this is not an array. try $update_products = array();
tadman Posted May 21, 2008 Author Posted May 21, 2008 the last case in the if test is: $update_products = ''; this is not an array. try $update_products = array(); You were right, I set the $update_totals = array() and now it works. Thanks a lot. Not sure why it works though, as before the javascript it was fine anyway. How the javascript would effect it is a mystery to me.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.