473,396 Members | 1,756 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

php if statement not being tested

201 100+
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!

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. mysql_select_db($database_Del_Comments, $Del_Comments);
  3. $result = sprintf("SELECT a.Id, a.Type, 
  4. a.Dates, 
  5. a.UIdFk as UIdFk, 
  6. b.Id as Did, 
  7. b.comment as Comment, 
  8. b.dates as Day, 
  9. b.sfk as Sfk ,
  10. aes_decrypt(e.ProfileName, '$Ukey') as Name,
  11. substr(i.PathThumb, 4) as Path
  12. FROM 
  13. asstatusupdate as a   
  14. left join asstatusdata as b 
  15. on a.id = b.sfk 
  16. right join onlyonew_hquis.ASWebInfo as e
  17. on e.Uidfk = a.uidfk
  18. right join onlyonew_hqups.ASManyAlbums as f
  19. on f.UserId=a.uidfk
  20. right join onlyonew_hqups.ASAlbums as g
  21. on f.AlbumId=g.Id
  22. right join onlyonew_hqups.ASTitle as h
  23. on g.Id=h.AlbumId
  24. right join onlyonew_hqups.ASData as i
  25. on h.Id=i.TitleId
  26. where a.uidfk in (select friendid from onlyonew_hquis.asfriends where uidfk0='1') and i.DefaultProfilePic='Y' order by dates desc;
  27. ");
  28. $statusUpdate = mysql_query($result, $Del_Comments);
  29.  
  30. $category_id = '';
  31.  
  32.         if(!empty($statusUpdate)) {
  33. while($row = mysql_fetch_array($statusUpdate)) {
  34.     if ($row['Id'] != $category_id) {
  35.         $category_id = $row['Id'];
  36.  
  37.     // grab table variables    
  38.         $Type = $row['Type'];
  39.         $Dates = $row['Dates'];
  40.         $Comment = $row['Comment'];
  41.         $Name = $row['Name'];
  42.         $Path = $row['Path'];
  43.         $FriendId = $row['UIdFk'];
  44.  
  45.         echo '<table align="center" width="60%" border="3" cellpadding="0" cellspacing="0">'; 
  46.         echo '<tr>';
  47.         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>';
  48.         echo '<td align="center"> '; echo "$Dates" ; echo "<br/>"; echo "<br/>"; echo "$Type"; //echo "</td>";
  49.         echo "<br/>"; 
  50.          echo "$Comment"; 
  51.          echo '<br/>'; 
  52.          echo '<br/>'; 
  53.          echo '</td>'; // echo "</br>";
  54.         echo '<td>'; echo "$category_id"; echo '</td>';
  55.         echo '</tr>';
  56.         echo '</table>';
  57.  
  58.  
  59.  
  60.  
  61. } // end of if
  62. mysql_select_db($database_Del_Comments, $Del_Comments);
  63. $comments= sprintf("SELECT 
  64. c.sfk as sfk1,
  65. c.UIdFk0,
  66. d.Memo as Memo,
  67. d.Date as Dates1,
  68. aes_decrypt(e.ProfileName, '$Ukey') as Name,
  69. substr(i.PathThumb, 4) as Path
  70. FROM 
  71. asmanystatusupdate as c
  72. left join ascomments as d
  73. on d.Id = c.CFk
  74. right join onlyonew_hquis.ASWebInfo as e
  75. on e.UIdFk = c.UIdFk0
  76. right join onlyonew_hqups.ASManyAlbums as f
  77. on f.UserId=c.UIdFk0
  78. right join onlyonew_hqups.ASAlbums as g
  79. on f.AlbumId=g.Id
  80. right join onlyonew_hqups.ASTitle as h
  81. on g.Id=h.AlbumId
  82. right join onlyonew_hqups.ASData as i
  83. on h.Id=i.TitleId
  84. 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;
  85. ");
  86. $status_comments = mysql_query($comments, $Del_Comments) or die(mysql_error());
  87.  
  88.  
  89. while($user_row = mysql_fetch_array($status_comments)){
  90.            // test the query
  91.             //if($row['sfk'] == $user_row['sfk']) {
  92.             {
  93.  
  94.             $Dates1 = $user_row['Dates1'];
  95.             $Memo = $user_row['Memo'];
  96.             $Name1 = $user_row['Name'];
  97.             $Path1 = $user_row['Path'];
  98.             $FriendId1 = $user_row['UIdFk0'];
  99.             $SFK1 = $user_row['sfk1'];
  100.  
  101.             // display table
  102.  
  103.             //echo '<a href="#0'."$SFK1".'" onclick="toggle_visibility(\'foo1'."$SFK1".'\');" ;return false\" style=\"position:relative\">Click here to show records</a>'; //
  104.             //echo '<div id="foo1'."$SFK1".'"style="position:relative;display:none">'; // to show comment records                
  105.         echo '<table align="right" width="60%" border="3" cellpadding="0" cellspacing="0">'; 
  106.         echo '<tr>';
  107.         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>';
  108.         echo '<td align="center"> '; echo "$Dates1" ; echo "<br/>"; echo "<br/>"; //echo "</td>";
  109.         echo "<br/>"; 
  110.          echo "$Memo"; echo '</td>'; // echo "</br>";
  111.          echo '</tr>';
  112.         // echo '</table>';
  113.         //echo '</div>';
  114.             }
  115.             }
  116.    mysql_select_db($database_Del_Comments, $Del_Comments);
  117. $user_comments= sprintf("SELECT 
  118. c.sfk as sfk1,
  119. c.UIdFk0
  120. FROM 
  121. asmanystatusupdate as c
  122. 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;
  123. ");
  124. $user_row_comment = mysql_query($user_comments, $Del_Comments) or die(mysql_error());
  125.  
  126.  
  127.                 if(empty($user_row_comment)) {
  128.  
  129.                 echo '<tr>';
  130.                 echo '<td>'; echo '&nbsp;'; echo '</td>';
  131.                 echo '<td align="right">';
  132.  
  133.                 echo '<a href="#'."$category_id".'" onclick="toggle_visibility(\'foo'."$category_id".'\');" ;return false" style="position:relative" align="right">Comment </a>';
  134.                 echo '</td>';
  135.                 echo '</table>';
  136.     echo '<form action="' ."$editFormAction". '" method="post" name="form1" id="form1">';
  137.   echo '<tr>';            
  138.    echo '</tr>';
  139.   echo '<div id="foo'."$category_id".'"style="position:relative;display:none">';
  140.   echo '<table align="right">';
  141.     echo '<tr valign="baseline">';
  142.       echo '<td nowrap="nowrap" align="right">Memo:</td>';
  143.       echo '<td><input type="text" name="Memo" value="" size="32" /></td>';
  144.     echo '</tr>';
  145.     echo '<tr valign="baseline">';
  146.       echo '<td nowrap="nowrap" align="right">&nbsp;</td>';
  147.      echo ' <td nowrap="nowrap" align="right">&nbsp;</td>';
  148.    echo ' </tr>';
  149.     echo '<tr valign="baseline">';
  150.      echo ' <td nowrap="nowrap" align="right">&nbsp;SFK:' ."$category_id". ' testing</td>';
  151.      echo ' <td><input type="submit" value="Insert record" id="$category_id"/></td>';
  152.    echo ' </tr>';
  153.  echo ' </table>';
  154.   echo '<input type="hidden" name="Id" value="" />';
  155.   echo '<input type="hidden" name="Id" value="" />';
  156.  echo ' <input type="hidden" name="SFk" value="' ."$SFK1". '" />';
  157.  echo ' <input type="hidden" name="MM_insert" value="form1" />';
  158.  echo '</form>';
  159. echo '</div>';
  160.                     } //end of else
  161.  
  162.                 if (!empty($user_row_comment)) 
  163.                 { 
  164.                 echo '<tr>';
  165.                 echo '<td>'; echo '&nbsp;'; echo '</td>';
  166.                 echo '<td align="right">';
  167.  
  168.                 echo '<a href="#'."$SFK1".'" onclick="toggle_visibility(\'foo'."$SFK1".'\');" ;return false" style="position:relative" align="right">Comment </a>';
  169.                 echo '</td>';
  170.                 echo '</table>';
  171.     echo '<form action="' ."$editFormAction". '" method="post" name="form1" id="form1">';
  172.   echo '<tr>';            
  173.    echo '</tr>';
  174.   echo '<div id="foo'."$SFK1".'"style="position:relative;display:none">';
  175.   echo '<table align="right">';
  176.     echo '<tr valign="baseline">';
  177.       echo '<td nowrap="nowrap" align="right">Memo:</td>';
  178.       echo '<td><input type="text" name="Memo" value="" size="32" /></td>';
  179.     echo '</tr>';
  180.     echo '<tr valign="baseline">';
  181.       echo '<td nowrap="nowrap" align="right">&nbsp;</td>';
  182.      echo ' <td nowrap="nowrap" align="right">&nbsp;</td>';
  183.    echo ' </tr>';
  184.     echo '<tr valign="baseline">';
  185.      echo ' <td nowrap="nowrap" align="right">&nbsp;SFK:' ."$SFK1". '</td>';
  186.      echo ' <td><input type="submit" value="Insert record" id="$SFK1"/></td>';
  187.    echo ' </tr>';
  188.  echo ' </table>';
  189.   echo '<input type="hidden" name="Id" value="" />';
  190.   echo '<input type="hidden" name="Id" value="" />';
  191.  echo ' <input type="hidden" name="SFk" value="' ."$SFK1". '" />';
  192.  echo ' <input type="hidden" name="MM_insert" value="form1" />';
  193.  echo '</form>';
  194. echo '</div>';
  195.                 //} // end of if for row comment
  196.         //} // end of if
  197.             } // end of while loop
  198.  
  199.  
  200.                     } // end of if
  201.     //} // end of while loop
  202. }// end of main loop
  203. //echo '</table>';
  204. ?>
  205.  
May 19 '11 #1
2 1328
code green
1,726 Expert 1GB
You have posted a lot of code with no indication where the problem is.
If you mean this
Expand|Select|Wrap|Line Numbers
  1. $statusUpdate = mysql_query($result, $Del_Comments); 
  2. $category_id = ''; 
  3.         if(!empty($statusUpdate)) { 
Then mysql_query returns a record resource which is not empty.
FALSE is only returned on error which is empty
May 19 '11 #2
wizardry
201 100+
i've solved it sorry i didnt mention which result set it was involving. here is the solution:

Expand|Select|Wrap|Line Numbers
  1. if(mysql_num_rows($user_row_comment) == 0) {
  2.  
Expand|Select|Wrap|Line Numbers
  1. if (mysql_num_rows($user_row_comment) > 0) 
  2.                 {
  3.  
May 19 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

28
by: Fábio Mendes | last post by:
I'm sorry if it's an replicate. Either my e-mail program is messing with things or the python-list sent my msg to /dev/null. I couldn't find anything related in previous PEP's, so here it goes a...
30
by: John Bailo | last post by:
The c# *return* statement has been bothering me the past few months. I don't like the fact that you can have different code paths in a method and have multiple return statements. To me, it...
35
by: Thierry Loiseau | last post by:
Hello all, and Happy end year 2005 ! Well, I would like to obtain a list of all JavaScript var statement, With "for...in" perharps ? That is bellow my recent test here, but the problem is...
12
by: Philippe Martin | last post by:
Hi, This code works, but is it "appropriate" ? l_init = False if True == l_init and 1234 = l_value: print 'l_value is initialized' I know I can do this with a try but ...
6
by: Heiko Wundram | last post by:
Hi all! The following PEP tries to make the case for a slight unification of for statement and list comprehension syntax. Comments appreciated, including on the sample implementation. ===...
4
by: priyanka | last post by:
Hi there, I had a question. Is there any way of testing a string value in a switch statement. I have about 50 string values that can be in a string variable. I tried cheking them with the if...
21
by: aaron80v | last post by:
Hi, A simple question: In ANSI-C, how to specify a string as the expression for switch statement. eg switch (mystr) { case "ABC" : bleh... break;
1
by: priyanka2203 | last post by:
Hi guys, I have a doubt regarding the CASE statement. It might sound silly, but me being new to DB2, it is kind of a genuine doubt. Try helping me with this.. When we use a case statement...
2
by: Northern Eagle | last post by:
Hi, I have created a query that uses a value selected from a list box in a form. The problem is that I need the query to accept multiple parameters as well as individual ones. I tried to make the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.