tags:

views:

69

answers:

2

hi , in code there Warning

Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\xampp\htdocs\Join.php on line 69

but i can not solving where exactly >>

can you help me where the error in this code .

<?php 

   51. include("connect.php");

   53. $email = mysql_query("select MemberEmail from members where MemberID= '$id' ");
   54. while ($row = mysql_fetch_array($email))
   55.  {   

   57.  $memEmail=$row['MemberEmail'];

   }


  62.  $sql = mysql_query("select * from ninvite where recieverMemberEmail ='$memEmail'  and viwed= '0' order by  RoomID desc");

  64.  $num =mysql_num_rows($sql);


  67.  if ($sql and $num >0 )
      {
  69.   while($row=mysql_fetch_array($sql))
       {
  71.   $sender=$row['SenderMemberID'];

  73.   $room=$row['RoomID'];



  77.  $sql2 =mysql_query("select MemberName from members where MemberID ='$sender'  ");
  78.  $sql1 =mysql_query("select RoomName,RoomLogo from rooms where RoomID ='$room' ");
  79.  while($row=mysql_fetch_array($sql2))
    {
        $mem =$row['MemberName'];
    }

  84.   while($rows=mysql_fetch_array($sql1))
    {   
        $Ro =$rows['RoomName'];
        $logo = $rows['RoomLogo'];
     }
  89.  ?>

<form action="" method="post">
    <table align="center">
        <tr>


            <td colspan="3">
    <input type="hidden" name="invite_id" value="<?php echo $room; ?>" />
   <label> 
   </label> <br/>
    <label> <?php echo "   
you have  invite from  $mem to join  $Ro "; ?> </label>  

    <br/>
     <label>accept</label>
    <input name="radio1" type="radio" value="accpet"  />
     <label>reject</label>
    <input name="radio1" type="radio" value="Reject"  /><br/><br/>
  <input  align="" type="submit" name="submit" value="submit" />
      </td>

             <td colspan="3">
    <?php echo "<p align=''><img width='90' height='90' src='" .$logo. "' alt='' /></p>"; ?>
            </td>
        </tr>
    </table>
</form>




<?php



if (isset ($_POST['submit']))
    {
// connect to the mysql server
include ("connect.php");

// insert the data
$button=$_POST['radio1'];
$room = $_POST['invite_id'];




if ($button=='Reject' )
{

mysql_query("INSERT INTO joinroom (MemberID, RoomID) VALUES ('$id', '$room')");

$sql = ("DELETE FROM ninvite  WHERE RoomID = '$room'");
$R=mysql_query($sql);
// print a success message
echo " <center> success join this team <br></center>"; }

else 
{

echo "<center> reject this invite /center> ";
$sql = ("DELETE FROM ninvite WHERE RoomID = '$room' " );
$R=mysql_query($sql);
}

echo "  <meta http-equiv=\"refresh\" content=\"3;URL=Join2.php\">";


}  }  }




?>

Thanks alot

+2  A: 

Shouldn't viwed be viewed?

select *
from ninvite
where recieverMemberEmail = '$memEmail'
and viewed = '0'
order by RoomID desc
Mark Byers
I was gonna suggest that too until I saw `ninvite` and `recieverMemberEmail` and figured I'd just stay out of it.
webbiedave
@webbiedave: Ah yep it should be `receiverMemberEmail`.
Mark Byers
A: 

I'm surprised you're not getting an error on line 64 (which also expects a resource). The SQL on line 62 is generating an error in the database. Temporarily change it to:

$sql = mysql_query("select * from ninvite where recieverMemberEmail ='$memEmail'  and viwed= '0' order by  RoomID desc") or die(mysql_error());

and inspect the printed error message.

webbiedave
you change but, the printed error message as still Warning: mysql_fetch_array() expects parameter 1 to be resource, string given in C:\xampp\htdocs\Join.php on line 69
We'll need to see more code then. You have missing lines that may hold the key.
webbiedave
I adding the fully code