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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.