Nexy Posted July 2, 2008 Share Posted July 2, 2008 Why Hello There! I don't understand why the following won't echo anything: <?php if($_GET['page'] == "PM") { if($_SESSION['user']) { $sql = "SELECT * FROM pm_inbox WHERE user = '".$_SESSION['user']."' ORDER BY id DESC"; } else if($_COOKIE['user']) { $sql = "SELECT * FROM pm_inbox WHERE user = '".$_COOKIE['user']."' ORDER BY id DESC"; } $res = mysql_query($sql) OR die(mysql_error()); $db = mysql_fetch_array($res); if($_GET['pg'] == "inbox") { while($db = mysql_fetch_array($res)) { echo "<div class='pm_inbox'> <table> <tr> <td> </td> <td>From:</td> <td>Subject:</td> <td>Date:</td> <td>Status</td> </tr> <tr> <td><input type='checkbox' id='$del' name='delete[]' value='$del' style='border: 0' /></td> <td><a href='index.php?page=Profile&user=".$db['from']."'>" . $db['from'] . '</a></td>'; echo "<td><a href='index.php?page=PM&pg=read&do=".$db['id']."'>" . $db['subject'] . '</a></td> <td>' . $db['date'] . '</td> <td>' . $db['status'] . '</td> </tr> </table> </div>'; } } } ?> I get no errors, it just doesn't display anything on the page. There is 1 entry into pm_inbox, so it should spit out something at least. Any help would be appreciated. Thank You! Link to comment https://forums.phpfreaks.com/topic/112934-solved-while-not-working/ Share on other sites More sharing options...
lemmin Posted July 2, 2008 Share Posted July 2, 2008 Try print_r($_GET). My guess is that those variables in that array are not what you expect. Link to comment https://forums.phpfreaks.com/topic/112934-solved-while-not-working/#findComment-580112 Share on other sites More sharing options...
Nexy Posted July 2, 2008 Author Share Posted July 2, 2008 I put that before the while statement and I got this: Array ( => PM [pg] => inbox ) when I put it inside the while statement, it doesn't show anything. Link to comment https://forums.phpfreaks.com/topic/112934-solved-while-not-working/#findComment-580113 Share on other sites More sharing options...
PFMaBiSmAd Posted July 2, 2008 Share Posted July 2, 2008 Your code contains the following line immediately after the mysql_query() statement and before the while() loop - $db = mysql_fetch_array($res); Why is that line in your code? It is fetching and discarding the first row (if any) from the result set. Link to comment https://forums.phpfreaks.com/topic/112934-solved-while-not-working/#findComment-580120 Share on other sites More sharing options...
Nexy Posted July 2, 2008 Author Share Posted July 2, 2008 I have that there because I also have in the code: if($_GET['pg'] == "read") Right after if($_GET['pg'] == "inbox") ends. So I thought it would be some ease of access instead of making a new query for the pg == read part. I'll take it out and see what happens. Link to comment https://forums.phpfreaks.com/topic/112934-solved-while-not-working/#findComment-580126 Share on other sites More sharing options...
Nexy Posted July 2, 2008 Author Share Posted July 2, 2008 You were right, I took it out and it the 1st row appeared. Thank You! Link to comment https://forums.phpfreaks.com/topic/112934-solved-while-not-working/#findComment-580134 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.