Jump to content

Problems calling a mysql query with php


Fenhopi

Recommended Posts

Hi, I'm working on a friend system for my website.

I'm having some problems with the view pending friend requests page.

The way I have it, is if status is: 0=Friendship requested by another user, 1=already in a friendship.

 

"status" is an INT column in my database.

 

So I did this:


   $status = "SELECT status FROM friends2 WHERE user2='$username'";
   
   $test = $database->query($status);

//If user is 0 (not a friend) then display him and give options to accept or deny request
  if($test == '0'){
   		for($i=0; $i<$num_rows; $i++){
      		$uname  = mysql_result($result,$i,"user1");
 		echo "<a href=\"userinfo.php?user=$uname\"><h3>$uname</h3></a>has requested to become your friend    ";
 		echo "<a href=\"accept.php\">Accept</a>  ";
  		echo "<a href=\"reject.php\">Reject</a><br><br>"; 
   		}
   }
   else{
   echo "No pending requests";
   }


}

 

I'm not getting any errors, but it's obvious that it does not understand my if statement.

Please help me find a solution. Thank you.

Link to comment
https://forums.phpfreaks.com/topic/201988-problems-calling-a-mysql-query-with-php/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.