473,406 Members | 2,259 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Warning: Invalid argument supplied for foreach() in line no........

i have dynamically created checkbox which will like yahoo mail if check box selected it will highlight a row but deleteall function is not working plz chek it

Expand|Select|Wrap|Line Numbers
  1. function doDeleteAll($objArray){
  2.  
  3.     foreach($objArray['frmcheckall'] as $strkey=>$strValue) {
  4.  
  5.             $strDeleteId = $strValue;
  6.  
  7.              doDelete($strDeleteId);
  8.  
  9.         }
  10.     }
  11. function doDelete($strDeleteId){
  12.  
  13. $strQuery = "UPDATE
  14.                          tbl_categories 
  15.                          SET 
  16.                               IsDeleted = 'Yes' 
  17.                          WHERE  
  18.                               CategoryId = '".$strDeleteId."'";
  19.         if(ExecuteQry($strQuery))
  20.             return 1;
  21.         else
  22.             return 0;
  23.  
  24.     }
  25.  
  26.  
  27. <tr class="tablehead" id="frmcheck<?php print $i; ?>">
  28.       <td height="25" align="center"><input name="frmcheckall<?php //print $i; ?>" type="checkbox" id="frmcheckall<?php print $i; ?>" value="<? print $strValue[$i]['CategoryId']; ?>" onclick="highlightRow('frmcheckall<?php print $i; ?>','frmcheck<?php print $i; ?>');" />
  29.       </td>
  30.       <td class="tablecontent"><? print $strValue[$i]['CategoryName']; ?></td>
  31.       <td align="center" class="tablecontent"><a href="edit.php?id=<? print $strValue[$i]['CategoryId']; ?>">Edit</a>
  32.         | <a href="javascript:deleteConfirm('cateogrylist.php?id=<? print $strValue[$i]['CategoryId']; ?>')">Delete
  33.         </a> </td>
  34.     </tr>
Oct 29 '08 #1
14 3320
code green
1,726 Expert 1GB
Assuming title is the error then $objArray is empty
Oct 29 '08 #2
Markus
6,050 Expert 4TB
Hey there, Rashgang.

When posting code on the forums, be sure to use [code] tags. [code] .. code goes here [/code]. If you neglect to do so, you will be given a warning and possibly a temporary ban. Please read the Posting Guidelines on How To Ask A Question

Markus.
Oct 29 '08 #3
r035198x
13,262 8TB
Is $objArray['frmcheckall'] an array as well or is $objArray the only array?
Oct 30 '08 #4
its a php script coding plz answer for it
this is the first time i am posting a question thats y
Oct 30 '08 #5
this function include in the main page of php
Expand|Select|Wrap|Line Numbers
  1.   function doDeleteAll($objArray){
  2.  
  3.         foreach($objArray['frmcheckall'] as $strkey=>$strValue) {
  4.  
  5.              $strDeleteId = $strValue;
  6.  
  7.                doDelete($strDeleteId);
  8.  
  9.             }
  10.      }
  11.   function doDelete($strDeleteId){
  12.  
  13.    $strQuery = "UPDATE
  14.                           tbl_categories 
  15.                         SET 
  16.                               IsDeleted = 'Yes' 
  17.                           WHERE  
  18.                              CategoryId = '".$strDeleteId."'";
  19.          if(ExecuteQry($strQuery))
  20.              return 1;
  21.          else
  22.                return 0;
  23.  
  24.       }
  25.  
  26.  
  27.   <tr class="tablehead" id="frmcheck<?php print $i; ?>">
  28.        <td height="25" align="center"><input name="frmcheckall<?php //print $i; ?>" type="checkbox" id="frmcheckall<?php print $i; ?>" value="<? print $strValue[$i]['CategoryId']; ?>" onclick="highlightRow('frmcheckall<?php print $i; ?>','frmcheck<?php print $i; ?>');" />
  29.      </td>
  30.         <td class="tablecontent"><? print $strValue[$i]['CategoryName']; ?></td>
  31.          <td align="center" class="tablecontent"><a href="edit.php?id=<? print $strValue[$i]['CategoryId']; ?>">Edit</a>
  32.            | <a href="javascript:deleteConfirm('cateogrylist.php?id=<? print $strValue[$i]['CategoryId']; ?>')">Delete
  33.          </a> </td>
  34.      </tr>
Oct 30 '08 #6
r035198x
13,262 8TB
its a php script coding plz answer for it
this is the first time i am posting a question thats y
Of course it's a PHP script. That's why you posted it in the PHP forum.
That foreach requires that first argument to be an array expression. That's why I asked if you are sure that your first argument is an array.
Oct 30 '08 #7
code green
1,726 Expert 1GB
Has somebody upset rashgang?
Oct 30 '08 #8
r035198x
13,262 8TB
Has somebody upset rashgang?
I don't think so(not sure actually).
Oct 30 '08 #9
Markus
6,050 Expert 4TB
Rashgang, you have been told previously to use code tags in this thread!. You have now received a warning, and a continuation of this behaviour will typically result in a ban of some sort. It is in your best interests to follow the Posting Guidelines.

Markus.
Oct 30 '08 #10
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  include "includes/connection.php";
  3.  include "includes/Functions_category.php";
  4.  include "includes/functions_db.php";
  5.  $Strtitle="Category Management (Category Listing)";
  6.  $strAddedDate=date("Y-m-d h:m:s");
  7.  
  8.     if($_POST['frmcheckall']){    
  9.        print doDeleteAll($_POST);
  10.  
  11.    }
  12.        if(isset($_GET['id'])){
  13.     //if($_POST['id']){
  14.     //$strDelete=doDeleteAll['id'];
  15.    // }
  16.     if(!doDelete($_GET['id'])){$strMessage= "Invalid Inputs Detected!";}
  17.    }
  18.  
  19.  
  20.  include"includes/pagestart.php"; ?>
  21. <link href="css/fonts.css" rel="stylesheet" type="text/css">
  22. <script type="text/javascript">
  23. function checkAll(field){
  24.  field=document.frmcategory.frmcheckall;
  25.  for (i = 0; i < field.length; i++){
  26.  field[i].checked = true;
  27.  highlightRow('frmcheckall'+i,'frmcheck'+i);
  28.  }
  29.  }
  30. function uncheckAll(field){
  31.  field=document.frmcategory.frmcheckall;
  32.  for (i = 0; i < field.length; i++){
  33.  field[i].checked = false;
  34.  highlightRow('frmcheckall'+i,'frmcheck'+i);
  35.  }
  36.  }
  37. /*function deleteall(field){
  38.  
  39.     field=document.frmcateogry.frmcheckall;
  40.  flag=0;
  41.  for(i=0;i< field.length;i++){
  42.  
  43.   if(field[i].checked)
  44.   flag=1;
  45.   }
  46.  if(flag==1){
  47.    alert("Hi");
  48.    document.frmcateogry.frmcheckall.submit();
  49.  }else
  50.    alert("Please select one category to Delete");
  51.  }*/
  52.  function deleted(field){
  53.  //field=document.frmcategory.frmcheckall;
  54.   flag=0;
  55.   for(i=0;i< field.length;i++){
  56.    if(field[i].checked)
  57.    flag=1;
  58.   }
  59.  
  60.   if(flag==1){
  61.    if(confirm("Are You Sure To Delete The Category List?")){
  62.    field.submit();
  63.    }
  64.   }else
  65.    alert("Please Select One Category To DELETE");
  66.  }
  67.  function highlightRow(id,id1) { //alert(id1);
  68.  
  69.   if (document.getElementById(id).checked) {
  70.  
  71.    document.getElementById(id1).bgColor = '#E2E6A8';
  72.   }
  73.   else {
  74.  
  75.    document.getElementById(id1).bgColor = '#FFFFFF';
  76.   }
  77.   }
  78.  
  79. function deleteConfirm(delUrl) {
  80.   if (confirm("Are You Sure To Delete This Category?")) {
  81.     document.location = delUrl;
  82.     }
  83.   }
  84. </script>
  85. <form name="frmcategory" method="post" action="">
  86.  
  87.   <table width="90%" border="0" cellspacing="3" cellpadding="3" align="center">
  88.   <tr><td><? print $strMessage ;?></td></tr>
  89.     <tr>
  90.       <td align="center">
  91.         <?
  92.   $strQuery="select * from tbl_categories where IsDeleted='No'";
  93.   $strValue=SelectQry($strQuery);
  94.    if(is_array($strValue)){
  95.    ?>
  96.         <span class="tablehead">Category List</span></td>
  97.     </tr>
  98.   </table>
  99.   <div align="center">&nbsp;
  100.     <table width="414" height="20" border="0" cellpadding="0" cellspacing="0" class="size">
  101.       <tr>
  102.         <td width="414" class="headerfont"><a href="javascript:onclick=checkAll();" class="headerfont">SELECT
  103.           ALL | </a><a href="javascript:onclick=uncheckAll();" class="headerfont">UNSELECT
  104.           ALL </a>| <a href="javascript:onclick=deleted(frmcategory);" class="headerfont">DELETE
  105.           SELECTED </a></td>
  106.       </tr>
  107.     </table>
  108.   </div>
  109.   <table width="421" border="1" align="center" cellpadding="5" cellspacing="0" bordercolor="#999999" class="headerfont" style="border-collapse:collapse">
  110.     <tr class="tablehead">
  111.       <td width="44" height="29">&nbsp;</td>
  112.       <td width="278" align="center">CATEGORY NAME </td>
  113.       <td width="179" align="center">ACTION </td>
  114.     </tr>
  115.     <?
  116.  //while($rows = mysql_fetch_object($stredit)){
  117.  for($i=0;$i<count($strValue);$i++) {
  118.   ?>
  119.     <tr class="tablehead" id="frmcheck<?php print $i; ?>">
  120.       <td height="25" align="center"><input name="frmcheckall" type="checkbox" id="frmcheckall<?php print $i; ?>" value="<? print $strValue[$i]['CategoryId']; ?>" onclick="highlightRow('frmcheckall<?php print $i; ?>','frmcheck<?php print $i; ?>');" />
  121.       </td>
  122.       <td class="tablecontent"><? print $strValue[$i]['CategoryName']; ?></td>
  123.       <td align="center" class="tablecontent"><a href="edit.php?id=<? print $strValue[$i]['CategoryId']; ?>">Edit</a>
  124.         | <a href="javascript:deleteConfirm('cateogrylist.php?id=<? print $strValue[$i]['CategoryId']; ?>')">Delete
  125.         </a> </td>
  126.     </tr>
  127.     <?
  128.  }
  129. //mysql_free_result($stredit);
  130. ?>
  131.     <tr align="left" class="tablehead">
  132.       <td height="25" colspan="3"><span class="tablecontent2"><a href="javascript:onclick=checkAll();" class="size">Select
  133.         all | </a><a href="javascript:onclick=uncheckAll();" class="size">UnSelect
  134.         All</a> | <a href="javascript:onclick=deleted(frmcategory);" class="size">Delete
  135.         SELECTED </a></span>
  136.         <div align="center"></div>
  137.         <div align="center"></div></td>
  138.     </tr>
  139.     <? }else{?>
  140.     <font face="Verdana, Arial, Helvetica, sans-serif" size="+1" color="#FF0000">
  141.     <center>
  142.       <? print "Sorry!No Records Found !!!";?>
  143.     </center>
  144.     </font>
  145.     <? }?>
  146.   </table>
  147.  
  148.   <p class="headerfont">&nbsp;</p>
  149. </form>
  150. <? include "includes/pageend.php"; ?>
  151.  
  152. this is the function category coding
  153.  
  154. <?
  155. function doDeleteAll($objArray){
  156.  
  157.  
  158.     foreach((array)$objArray['frmcheckall'] as $strkey=>$strValue) {
  159.             $strDeleteId = $strValue;
  160.  
  161.              doDelete($strDeleteId);
  162.               //print_r($strDeleteId);
  163.                         /*$strQuery=  "UPDATE 
  164.                            tbl_categories  
  165.                           SET 
  166.                               IsDeleted = 'Yes' 
  167.                           WHERE
  168.                               Ident =".$strDeleteId." 
  169.                            LIMIT 1";*/
  170.  
  171.                           //doDelete($objGetArray['id']);
  172.  
  173. /*if(doDelete($objGetArray['id'])){
  174.             return 1;
  175.             //print_r(($objGetArray['id']));
  176.             }
  177.             else{
  178.             return 0;}*/
  179.         }
  180.     }
  181.  
  182. /*function doDelete($objGetArray){
  183.     if(is_numeric($objGetArray['id'])){
  184.         $strQuery="SELECT * 
  185.                    FROM
  186.                           tbl_categories 
  187.                    WHERE 
  188.                       Ident=".$objGetArray['id'];
  189.         $strRows = SelectQry($strQuery);
  190.         if(is_array($strRows)){
  191.             $strQuery = "UPDATE
  192.                              tbl_categories 
  193.                          SET 
  194.                               IsDeleted = 'Yes' 
  195.                          WHERE  
  196.                               Ident =".$objGetArray['id']." 
  197.                          LIMIT 1";
  198.             ExecuteQry($strQuery);
  199.             return 1;
  200.         }else{
  201.             return 0;
  202.         }
  203.     }else{
  204.             return 0;
  205.     }
  206. } */
  207. function doDelete($strDeleteId){
  208. //print_r($objGetArray);
  209. //if($objGetArray['id']){
  210. $strQuery = "UPDATE
  211.                          tbl_categories 
  212.                          SET 
  213.                               IsDeleted = 'Yes' 
  214.                          WHERE  
  215.                               CategoryId = '".$strDeleteId."'";
  216.  // print_r($strQuery);
  217.         if(ExecuteQry($strQuery))
  218.             return 1;
  219.         else
  220.             return 0;
  221.  
  222.     }
  223.  
  224. ?>
Oct 31 '08 #11
nathj
938 Expert 512MB
I'd love to help but I can't bothered to find the line.

Use code tags and you get line numbers and people are much more likely to help you out.

nathj
Oct 31 '08 #12
Markus
6,050 Expert 4TB
rashgang, you are precariously close to border between ignorance and justified newby-ness. You have, in 4 posts, double posted and not once used code tags - something you were previously warned about. Therefore, this is your second formal warning. Please take note of this or you may receive a ban.

Posting Guidelines - read them.
Oct 31 '08 #13
thank u for ur advice then i have tagged the php see clearly i have used code tags for example <?php
?>
Nov 1 '08 #14
Markus
6,050 Expert 4TB
thank u for ur advice then i have tagged the php see clearly i have used code tags for example <?php
?>
If you look at post 3 you will see I explain what code tags are.
Nov 1 '08 #15

Sign in to post your reply or Sign up for a free account.

Similar topics

35
by: jerrygarciuh | last post by:
Hi all, I was just wondering what popular opinion is on PHP giving this warning: Warning: Invalid argument supplied for foreach() in /home/boogerpic/public_html/my.php on line 6 when...
4
by: Ryanlawrence1 | last post by:
Heya, I get these 2 errors: Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/themepar/public_html/changepass.php on line 20 You have not entered all the...
2
by: techjohnny | last post by:
Error: Warning: mysql_query(): supplied argument is not a valid MySQL-Link resource in /home/jplane/certcent/phpweb/quiz/index.php on line 20 Warning: mysql_num_rows(): supplied argument is...
1
by: lsmamadele | last post by:
I am getting the following error messages in my search: Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/mamadele/public_html/BESTPLAYS/search.php on...
11
by: Breana | last post by:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/breana/public_html/category.php on line 88 ------------------------------------------- It does this...
2
by: yogitha | last post by:
For the below code i am getting an error like : --------------------------------------------------------------- Warning: fread(): supplied argument is not a valid stream resource in...
1
by: custom3 | last post by:
Hello, I keep getting the following warning: "PHP Warning: Invalid argument supplied for foreach() in /home/csiexecu/public_html/modules/mod_mainmenu.php on line 339" I am a novice Joomla...
1
by: guoxin | last post by:
Hi All, May i know how to rectify the following php error? Thanks folks Warning: Invalid argument supplied for foreach() in /home/alan/do_add-user.php on line 36 do_add-user.php.php on...
11
by: chemlight | last post by:
I'm having a problem. I'm sure I'm going to kick myself over the answer... I have a table that stores vendors and their languages. This table starts out blank. I am querying the table to see if a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.