GB_001 Posted February 12, 2009 Share Posted February 12, 2009 <?php session_start(); include('Connect.php'); $User=$_SESSION['email']; $resulter = mysql_query("SELECT * FROM Friends WHERE (user='$User' AND pending=0) OR (friend='$User' AND pending=0) ")or die(mysql_error()); while($rowf=mysql_fetch_array($resulter) or die(mysql_error())) { $po1=$rowf['user']; $po2=$rowf['friend'] if($po1==$User) { $Friend=$po2; }else { $Friend=$po1; } $resultn = mysql_query("SELECT * FROM News WHERE Who='$Friend' LIMIT 1")or die(mysql_error()); $rown=mysql_fetch_array($resultn) or die(mysql_error()); $N3=$rown['Who']; $N1=$rown['What']; $N2=$rown['Time']; echo"$N3 $N1 $N2<br>"; } ?> For some reason the code does not work, I even tried to echo something at the end to see if it's an infinite loop and it didn't echo, so I'm guessing it is. Please help. -GB Quote Link to comment Share on other sites More sharing options...
drisate Posted February 12, 2009 Share Posted February 12, 2009 Umm you have an error in your code $po2=$rowf['friend'] you forgot ; $po2=$rowf['friend']; If you have error turned off if would result in a blank page ;-) Quote Link to comment Share on other sites More sharing options...
printf Posted February 12, 2009 Share Posted February 12, 2009 What this... while($rowf=mysql_fetch_array($resulter) or die(mysql_error())) mysql_fetch_array() return false when their are not any more rows, it's has nothing to do with an error! Quote Link to comment Share on other sites More sharing options...
GB_001 Posted February 12, 2009 Author Share Posted February 12, 2009 Thanks, I'm going to smack myself. =P. Quote Link to comment Share on other sites More sharing options...
drisate Posted February 12, 2009 Share Posted February 12, 2009 Can i smack you to :-P Quote Link to comment Share on other sites More sharing options...
printf Posted February 12, 2009 Share Posted February 12, 2009 Also don't copy variables when you don't need to, you waste memory that way. Sure its not a problem for a mom and pop site, but it's better to not learn bad habits! <?php session_start (); include 'Connect.php'; $resulter = mysql_query ( "SELECT * FROM Friends WHERE user = '" . $_SESSION['email'] . "' AND pending = 0 OR friend = '" . $_SESSION['email'] . "' AND pending = 0;" ) or die ( mysql_error () ); if ( mysql_num_rows ( $resulter ) > 0 ) { while ( $rowf = mysql_fetch_assoc ( $resulter ) ) { if ( $rowf['user'] == $_SESSION['email'] ) { $Friend = $rowf['friend']; } else { $Friend = $rowf['user']; } $resultn = mysql_query ( "SELECT * FROM News WHERE Who = '" . $Friend . "' LIMIT 1;" ) or die ( mysql_error () ); if ( mysql_num_rows ( $resultn ) > 0 ) { echo $rown['Who'] . ' ' . $rown['What'] . ' ' $rown['Time'] . '<br>'; } } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.