It is showing error about foreach loop. Error is:


Warning: Invalid argument supplied for foreach() in D:\wamp\www\greenmusic\admin\sec.php on line 408

<form id="adminsform" name="adminsform" method="post" action="">
<input type="checkbox" name="master" onClick="checkedAll('adminsform')" value=""/>
<?php while($row=mysql_fetch_array($result))
                  {  ?>
                  
                    <input type="checkbox" name="musicid[]" value="<?=$row['id']?>" />

                    <?=$row['song']?>

                    <?=$row['singername']?>

                   <?=$row['songtype']?>
                    
                    <td width="15%"><?=$row['songtypeav']?></td>
                    <?php if($row['songtypeav']=="Audio Song") { ?>
                    <a href="sec.php?id=<?=$row['id']?>&act=play">Play</a><?=" "?><a href="edit.php?id=<?=$row['id']?>">Edit</a>
                    <?php } if($row['songtypeav']=="Video Song") { ?>
                     <a href="vidsong.php?id=<?=$row['id']?>">Play</a><?=" "?><a href="edit.php?id=<?=$row['id']?>">Edit</a>
                    <?php } ?>
                  
if(isset($_REQUEST['ac'])){


   foreach($_REQUEST['musicid'] as $ids) 
 {
 	$mdquery="DELETE FROM members WHERE id='$ids'";
 	mysql_query($mdquery);
 	
 	
 	//header('Location:sec.php');
 }

 }
</form>

Hi

I think you have missed } before </form>.

Pls check it

what are u try to do with

<?=$row['song']?>

if u wan to display $row

<? echo $row['song']; ?>

your code will look like

<form id="adminsform" name="adminsform" method="post" action="">
<input type="checkbox" name="master" onClick="checkedAll('adminsform')" value=""/>
<?php 
while($row=mysql_fetch_array($result))
	{  ?>
   <input type="checkbox" name="musicid[]" value="<?php echo $row['id']; ?>" />
   <?php echo $row['song']." ".$row['singername']." ".$row['songtype']; ?>
 
   <td width="15%"><?=$row['songtypeav']; ?></td>
   <?php 
   if($row['songtypeav']=="Audio Song") 
   			{ ?>
            <a href="sec.php?id=<?php echo $row['id']; ?>&act=play">Play</a>
            &nbsp
            <a href="edit.php?id=<?php echo $row['id']; ?>">Edit</a>
      <?php } 
   if($row['songtypeav']=="Video Song") 
   			{ ?>
           <a href="vidsong.php?id=<?php echo $row['id']; ?>">Play</a>
           &nbsp
           <a href="edit.php?id=<?php echo $row['id']; ?>">Edit</a>
      <?php } 
	                
   if(isset($_REQUEST['ac']))
		{
   		foreach($_REQUEST['musicid'] as $ids) 
 			{
 			$mdquery="DELETE FROM members WHERE id='$ids'";
 			mysql_query($mdquery);
 			//header('Location:sec.php');
 			}
 		}
	}?>
</form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.