Jump to content

why isn't this working?


ohdang888

Recommended Posts

ok so i have a notification system that tells users if there is a friend request or message. But when there's nothing, it won't display "Nothing =("

 

i've marked where the problem most likely is, but i obivously don't know for sure if thats the problem.

 

<?php
$result = mysql_query("SELECT `1`,`2` FROM `friend_requests` WHERE `id`='{$id}'") or die(mysql_error());
$new_friends = mysql_fetch_array($result);

$new_request1 = stripslashes($new_friends['1']);
$new_request2 = stripslashes($new_friends['2']);

if($new_request1 != 0){
if($new_request2 != 0){
	Echo '<a href="friend_request.php">New Friend Requests</a>';
}else{
Echo '<a href="friend_request.php">New Friend Request</a>';

}
}else{
$new_friends0 = 'none';// here?
}

$result = mysql_query("SELECT `id` FROM `messages` WHERE `to`='{$id}' and `read`='0'") or die(mysql_error());
$count = mysql_num_rows($result);

while($row = mysql_fetch_assoc($result)){
if(strlen($row['id']) > 0){
echo '<br>You have '.$count.' new messages!';
}else{
$new_messages = 'none'; //here?
}
}

if($new_friends0 == 'none'){
if($new_messages == 'none'){// around here
echo 'Nothing =(';
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/95287-why-isnt-this-working/
Share on other sites

Try this:

 

<?php
$result = mysql_query("SELECT `1`,`2` FROM `friend_requests` WHERE `id`='{$id}'") or die(mysql_error());
$new_friends = mysql_fetch_array($result);

$new_request1 = stripslashes($new_friends['1']);
$new_request2 = stripslashes($new_friends['2']);

if($new_request1 != 0){
if($new_request2 != 0){
	Echo '<a href="friend_request.php">New Friend Requests</a>';
}else{
Echo '<a href="friend_request.php">New Friend Request</a>';

}
}else{
$new_friends0 = 'none';// here?
}

$result2 = mysql_query("SELECT `id` FROM `messages` WHERE `to`='{$id}' and `read`='0'") or die(mysql_error());
$count = mysql_num_rows($result2);

while($row = mysql_fetch_assoc($result2)){
if(strlen($row['id']) > 0){
echo '<br>You have '.$count.' new messages!';
}else{
$new_messages = 'none'; //here?
}
}

if ((mysql_num_rows($result) < 1) && (mysql_num_rows($result2) < 1)){
echo 'Nothing =(';
}

?>

Link to comment
https://forums.phpfreaks.com/topic/95287-why-isnt-this-working/#findComment-488034
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.