Jump to content

[SOLVED] Ballon if that should read true don't


laPistola

Recommended Posts

<?php require_once('Connections/bedroomBlogsDB.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}


if (isset($_SESSION['MM_Username'])) {
// get logged in member
$colname_memberRS = "-1";
if (isset($_SESSION['MM_Username'])) {
  $colname_memberRS = $_SESSION['MM_Username'];
}
mysql_select_db($database_bedroomBlogsDB, $bedroomBlogsDB);
$query_memberRS = sprintf("SELECT id FROM members WHERE username = %s", GetSQLValueString($colname_memberRS, "text"));
$memberRS = mysql_query($query_memberRS, $bedroomBlogsDB) or die(mysql_error());
$row_memberRS = mysql_fetch_assoc($memberRS);
$totalRows_memberRS = mysql_num_rows($memberRS);

$getUID = $row_memberRS['id']; // logged in members UID

mysql_select_db($database_bedroomBlogsDB, $bedroomBlogsDB);
$query_messagesRS = "SELECT `to`, `sent` FROM messages WHERE (`to` = '".$getUID."' AND status = '0')";
$messagesRS = mysql_query($query_messagesRS, $bedroomBlogsDB) or die(mysql_error());
$row_messagesRS = mysql_fetch_assoc($messagesRS);
$totalRows_messagesRS = mysql_num_rows($messagesRS);

$mFromUID = $row_messagesRS['sent'];

mysql_select_db($database_bedroomBlogsDB, $bedroomBlogsDB);
$query_messageFromRS = "SELECT username FROM members WHERE id = '".$mFromUID."'";
$messageFromRS = mysql_query($query_messageFromRS, $bedroomBlogsDB) or die(mysql_error());
$row_messageFromRS = mysql_fetch_assoc($messageFromRS);
$totalRows_messageFromRS = mysql_num_rows($messageFromRS);

$mFromUN = $row_messageFromRS['username'];

mysql_select_db($database_bedroomBlogsDB, $bedroomBlogsDB);
$query_friendshipRequestsRS = "SELECT uid FROM friends_list WHERE (fid = '".$getUID."' AND status = '0')" ;
$friendshipRequestsRS = mysql_query($query_friendshipRequestsRS, $bedroomBlogsDB) or die(mysql_error());
$row_friendshipRequestsRS = mysql_fetch_assoc($friendshipRequestsRS);
$totalRows_friendshipRequestsRS = mysql_num_rows($friendshipRequestsRS);

$rfFromUID = $row_friendshipRequestsRS['uid'];

mysql_select_db($database_bedroomBlogsDB, $bedroomBlogsDB);
$query_rfMemberRS = "SELECT username FROM members WHERE id = '".$rfFromUID."'";
$rfMemberRS = mysql_query($query_rfMemberRS, $bedroomBlogsDB) or die(mysql_error());
$row_rfMemberRS = mysql_fetch_assoc($rfMemberRS);
$totalRows_rfMemberRS = mysql_num_rows($rfMemberRS);

$rfUN = $row_rfMemberRS['username'];
$notiF = '-1';

// This bit
  function notiF() {
  $trM = $totalRows_messagesRS;
  $trRF = $totalRows_friendshipRequestsRS;
if (($trM>0) && ($trRF>0)) {
	return("<a href='friendConfirm.php'><ima src='images/notiFrf.png' alt='click to view' /></a> x".$totalRows_friendshipRequestsRS." <a href='inbox.php'><img src='images/notiFm.png' alt='Click to view' /></a> x".$totalRows_messagesRS);
} else if (($trM>1) && ($trRF<1)) {
	return("<a href='inbox.php'>You have ".$totalRows_messagesRS." messages <img src='images/notiFm.png' alt='Click to view' /></a>");
} else if (($trM==1) && ($trRF<1)) {
	return("<a href='inbox.php'>".substr($mFromUN,15,0)." has sent you a message <img src='images/notiFm.png' alt='Click to view' /></a>");
} else if (($trM<1) && ($trRF==1)) {  // This one should be true ??
	return("<a href='friendConfirm.php'>".substr($rfUN,15,0)." has requested your friendship <img src='images/notiFrf.png' alt='Click to view' /></a>");
} else if (($trM<1) && ($trRF>1)) {
	return("<a href='friendConfirm.php'>You have ".$totalRows_friendshipRequestsRS." waiting friends requests");
} else {
	return("none");
}
  }
$notiF = notiF();
// To this bit
mysql_free_result($memberRS);

mysql_free_result($messagesRS);

mysql_free_result($messageFromRS);

mysql_free_result($rfMemberRS);

mysql_free_result($friendshipRequestsRS);	
} else { // else to isset line 35
$notiF = ' ';
}

?>

 

Hello i have marked places in the above code in comments to show you which bit im talking about (// This bit) and (// This should be true)

 

Basicly every time the page is loaded the var is echoing the word none which is the else to function, now i have triple checked that $totalRows_messagesRS is o and $totalRows_friendshipRequestsRS is 1 but the else if that should read true isn't??

 

the MySQL server is 5.0.67

 

Any ideas??

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.