php if statement not being tested

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • wizardry
    New Member
    • Jan 2009
    • 201

    php if statement not being tested

    i'm trying to test to see if the results are empty or not empty and the results that i know are empty comeback with the results for a not empty query.

    i've ran var_dump() and it comes back that their is something their how do i work around this?

    thanks in advance for your help!

    Code:
    <?php
    mysql_select_db($database_Del_Comments, $Del_Comments);
    $result = sprintf("SELECT a.Id, a.Type, 
    a.Dates, 
    a.UIdFk as UIdFk, 
    b.Id as Did, 
    b.comment as Comment, 
    b.dates as Day, 
    b.sfk as Sfk ,
    aes_decrypt(e.ProfileName, '$Ukey') as Name,
    substr(i.PathThumb, 4) as Path
    FROM 
    asstatusupdate as a   
    left join asstatusdata as b 
    on a.id = b.sfk 
    right join onlyonew_hquis.ASWebInfo as e
    on e.Uidfk = a.uidfk
    right join onlyonew_hqups.ASManyAlbums as f
    on f.UserId=a.uidfk
    right join onlyonew_hqups.ASAlbums as g
    on f.AlbumId=g.Id
    right join onlyonew_hqups.ASTitle as h
    on g.Id=h.AlbumId
    right join onlyonew_hqups.ASData as i
    on h.Id=i.TitleId
    where a.uidfk in (select friendid from onlyonew_hquis.asfriends where uidfk0='1') and i.DefaultProfilePic='Y' order by dates desc;
    ");
    $statusUpdate = mysql_query($result, $Del_Comments);
    
    $category_id = '';
    
    		if(!empty($statusUpdate)) {
    while($row = mysql_fetch_array($statusUpdate)) {
    	if ($row['Id'] != $category_id) {
    		$category_id = $row['Id'];
    	
    	// grab table variables	
    	    $Type = $row['Type'];
    		$Dates = $row['Dates'];
    		$Comment = $row['Comment'];
    		$Name = $row['Name'];
    		$Path = $row['Path'];
    		$FriendId = $row['UIdFk'];
    		
    		echo '<table align="center" width="60%" border="3" cellpadding="0" cellspacing="0">'; 
    		echo '<tr>';
    		echo '<td align="center">'; echo "$Name"; echo "<br/>"; echo  '<a href="source/source.php?FriendId=' ."$FriendId". '"><img src="' ."$Path". '" height="100" width="100" align="middle" border="3" /></a>'; echo '</td>';
    		echo '<td align="center"> '; echo "$Dates" ; echo "<br/>"; echo "<br/>"; echo "$Type"; //echo "</td>";
    	    echo "<br/>"; 
    		 echo "$Comment"; 
    		 echo '<br/>'; 
    		 echo '<br/>'; 
    		 echo '</td>'; // echo "</br>";
    		echo '<td>'; echo "$category_id"; echo '</td>';
    		echo '</tr>';
    	    echo '</table>';
    
    		
    	
    	
    } // end of if
    mysql_select_db($database_Del_Comments, $Del_Comments);
    $comments= sprintf("SELECT 
    c.sfk as sfk1,
    c.UIdFk0,
    d.Memo as Memo,
    d.Date as Dates1,
    aes_decrypt(e.ProfileName, '$Ukey') as Name,
    substr(i.PathThumb, 4) as Path
    FROM 
    asmanystatusupdate as c
    left join ascomments as d
    on d.Id = c.CFk
    right join onlyonew_hquis.ASWebInfo as e
    on e.UIdFk = c.UIdFk0
    right join onlyonew_hqups.ASManyAlbums as f
    on f.UserId=c.UIdFk0
    right join onlyonew_hqups.ASAlbums as g
    on f.AlbumId=g.Id
    right join onlyonew_hqups.ASTitle as h
    on g.Id=h.AlbumId
    right join onlyonew_hqups.ASData as i
    on h.Id=i.TitleId
    where c.sfk={$row['Sfk']} AND c.UIdFk0 in (select FriendId from onlyonew_hquis.asfriends where UIdFk0='1') and i.DefaultProfilePic='Y' order by dates asc;
    ");
    $status_comments = mysql_query($comments, $Del_Comments) or die(mysql_error());
    
    
    while($user_row = mysql_fetch_array($status_comments)){
    	       // test the query
    			//if($row['sfk'] == $user_row['sfk']) {
    			{
    				
    			$Dates1 = $user_row['Dates1'];
    			$Memo = $user_row['Memo'];
    			$Name1 = $user_row['Name'];
    			$Path1 = $user_row['Path'];
    			$FriendId1 = $user_row['UIdFk0'];
    			$SFK1 = $user_row['sfk1'];
    			
    			// display table
    			
    			//echo '<a href="#0'."$SFK1".'" onclick="toggle_visibility(\'foo1'."$SFK1".'\');" ;return false\" style=\"position:relative\">Click here to show records</a>'; //
    			//echo '<div id="foo1'."$SFK1".'"style="position:relative;display:none">'; // to show comment records				
    		echo '<table align="right" width="60%" border="3" cellpadding="0" cellspacing="0">'; 
    		echo '<tr>';
    		echo '<td align="center">'; echo "$Name1"; echo "<br/>"; echo  '<a href="source/source.php?FriendId=' ."$FriendId1". '"><img src="' ."$Path1". '" height="100" width="100" align="middle" border="3" /></a>'; echo '</td>';
    		echo '<td align="center"> '; echo "$Dates1" ; echo "<br/>"; echo "<br/>"; //echo "</td>";
    	    echo "<br/>"; 
    		 echo "$Memo"; echo '</td>'; // echo "</br>";
    		 echo '</tr>';
    		// echo '</table>';
    		//echo '</div>';
    			}
    			}
       mysql_select_db($database_Del_Comments, $Del_Comments);
    $user_comments= sprintf("SELECT 
    c.sfk as sfk1,
    c.UIdFk0
    FROM 
    asmanystatusupdate as c
    where c.sfk={$row['Sfk']} AND c.UIdFk0 in (select FriendId from onlyonew_hquis.asfriends where UIdFk0='1') order by c.sfk desc limit 1;
    ");
    $user_row_comment = mysql_query($user_comments, $Del_Comments) or die(mysql_error());
    
    				
    				if(empty($user_row_comment)) {
    						
    				echo '<tr>';
    				echo '<td>'; echo '&nbsp;'; echo '</td>';
    				echo '<td align="right">';
    								
    				echo '<a href="#'."$category_id".'" onclick="toggle_visibility(\'foo'."$category_id".'\');" ;return false" style="position:relative" align="right">Comment </a>';
    				echo '</td>';
    				echo '</table>';
    	echo '<form action="' ."$editFormAction". '" method="post" name="form1" id="form1">';
      echo '<tr>';			
       echo '</tr>';
      echo '<div id="foo'."$category_id".'"style="position:relative;display:none">';
      echo '<table align="right">';
        echo '<tr valign="baseline">';
          echo '<td nowrap="nowrap" align="right">Memo:</td>';
          echo '<td><input type="text" name="Memo" value="" size="32" /></td>';
        echo '</tr>';
        echo '<tr valign="baseline">';
          echo '<td nowrap="nowrap" align="right">&nbsp;</td>';
         echo ' <td nowrap="nowrap" align="right">&nbsp;</td>';
       echo ' </tr>';
        echo '<tr valign="baseline">';
         echo ' <td nowrap="nowrap" align="right">&nbsp;SFK:' ."$category_id". ' testing</td>';
         echo ' <td><input type="submit" value="Insert record" id="$category_id"/></td>';
       echo ' </tr>';
     echo ' </table>';
      echo '<input type="hidden" name="Id" value="" />';
      echo '<input type="hidden" name="Id" value="" />';
     echo ' <input type="hidden" name="SFk" value="' ."$SFK1". '" />';
     echo ' <input type="hidden" name="MM_insert" value="form1" />';
     echo '</form>';
    echo '</div>';
    					} //end of else
    
    				if (!empty($user_row_comment)) 
    				{ 
    				echo '<tr>';
    				echo '<td>'; echo '&nbsp;'; echo '</td>';
    				echo '<td align="right">';
    								
    				echo '<a href="#'."$SFK1".'" onclick="toggle_visibility(\'foo'."$SFK1".'\');" ;return false" style="position:relative" align="right">Comment </a>';
    				echo '</td>';
    				echo '</table>';
    	echo '<form action="' ."$editFormAction". '" method="post" name="form1" id="form1">';
      echo '<tr>';			
       echo '</tr>';
      echo '<div id="foo'."$SFK1".'"style="position:relative;display:none">';
      echo '<table align="right">';
        echo '<tr valign="baseline">';
          echo '<td nowrap="nowrap" align="right">Memo:</td>';
          echo '<td><input type="text" name="Memo" value="" size="32" /></td>';
        echo '</tr>';
        echo '<tr valign="baseline">';
          echo '<td nowrap="nowrap" align="right">&nbsp;</td>';
         echo ' <td nowrap="nowrap" align="right">&nbsp;</td>';
       echo ' </tr>';
        echo '<tr valign="baseline">';
         echo ' <td nowrap="nowrap" align="right">&nbsp;SFK:' ."$SFK1". '</td>';
         echo ' <td><input type="submit" value="Insert record" id="$SFK1"/></td>';
       echo ' </tr>';
     echo ' </table>';
      echo '<input type="hidden" name="Id" value="" />';
      echo '<input type="hidden" name="Id" value="" />';
     echo ' <input type="hidden" name="SFk" value="' ."$SFK1". '" />';
     echo ' <input type="hidden" name="MM_insert" value="form1" />';
     echo '</form>';
    echo '</div>';
    				//} // end of if for row comment
    		//} // end of if
    			} // end of while loop
    			
    										
    					} // end of if
    	//} // end of while loop
    }// end of main loop
    //echo '</table>';
    ?>
    Last edited by Niheel; May 19 '11, 08:37 PM.
  • code green
    Recognized Expert Top Contributor
    • Mar 2007
    • 1726

    #2
    You have posted a lot of code with no indication where the problem is.
    If you mean this
    Code:
    $statusUpdate = mysql_query($result, $Del_Comments); 
    $category_id = ''; 
            if(!empty($statusUpdate)) {
    Then mysql_query returns a record resource which is not empty.
    FALSE is only returned on error which is empty

    Comment

    • wizardry
      New Member
      • Jan 2009
      • 201

      #3
      i've solved it sorry i didnt mention which result set it was involving. here is the solution:

      Code:
      if(mysql_num_rows($user_row_comment) == 0) {
      Code:
      if (mysql_num_rows($user_row_comment) > 0) 
      				{

      Comment

      Working...