NLCJ Posted January 27, 2010 Share Posted January 27, 2010 Hello, I've got a problem with creating my own guestbook. It doesn't 'echo' all replies, it doesn't show the last value. So you've got to wait until it someone else replies before you can see it. <?php }elseif($p == gastenboek) { ?> <center>[<a href="?p=ngastenboek">Nieuwe reactie</a>]</center><br> <?php while($berichten = mysql_fetch_array($d_getberichten)) { ?> <div class="gastenboek"> <div class="informatie"> <?php $d_getgastenboekusers = mysql_query("SELECT * FROM users WHERE id='".mysql_real_escape_string($berichten['userid'])."'"); $d_gastenboekusers = mysql_fetch_array($d_getgastenboekusers); echo "Verzonden door <i>".$d_gastenboekusers['voornaam']." ".$d_gastenboekusers['achternaam']."</i> op ".$berichten['datum']." om ".$berichten['tijd']."."; ?> </div> <div class="bericht"> <?php echo "<b>".$berichten['titel']."</b><br>".$berichten['tekst']; ?> </div> </div> <?php } ?> Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/190037-not-all-values-from-mysql/ Share on other sites More sharing options...
akitchin Posted January 27, 2010 Share Posted January 27, 2010 it's hard to tell what's wrong without seeing the query that grabs the guestbook entries. Quote Link to comment https://forums.phpfreaks.com/topic/190037-not-all-values-from-mysql/#findComment-1002618 Share on other sites More sharing options...
NLCJ Posted January 27, 2010 Author Share Posted January 27, 2010 it's hard to tell what's wrong without seeing the query that grabs the guestbook entries. Sorry $d_getberichten = mysql_query("SELECT * FROM gastenboek ORDER BY datum,tijd DESC"); Quote Link to comment https://forums.phpfreaks.com/topic/190037-not-all-values-from-mysql/#findComment-1002621 Share on other sites More sharing options...
akitchin Posted January 27, 2010 Share Posted January 27, 2010 so the script currently echoes all but one of the replies? how and when are they being inserted? Quote Link to comment https://forums.phpfreaks.com/topic/190037-not-all-values-from-mysql/#findComment-1002631 Share on other sites More sharing options...
NLCJ Posted January 27, 2010 Author Share Posted January 27, 2010 so the script currently echoes all but one of the replies? how and when are they being inserted? It echoes every reply except the last one that is added, when somebody else adds another one that one won't show up, but others will. mysql_query("INSERT INTO gastenboek (userid,titel,tekst,datum,tijd) VALUES ('".mysql_real_escape_string($d_usergegevens['id'])."','".mysql_real_escape_string($titel)."','".mysql_real_escape_string($tekst)."','".mysql_real_escape_string($date)."','".mysql_real_escape_string($time)."')"); Quote Link to comment https://forums.phpfreaks.com/topic/190037-not-all-values-from-mysql/#findComment-1002636 Share on other sites More sharing options...
akitchin Posted January 27, 2010 Share Posted January 27, 2010 is the SELECT query being performed before the INSERT query on the same PHP page? does simply reloading the page without posting a new comment force the newest comment to be displayed? if not, have you checked what data your tables contain? Quote Link to comment https://forums.phpfreaks.com/topic/190037-not-all-values-from-mysql/#findComment-1002643 Share on other sites More sharing options...
NLCJ Posted January 27, 2010 Author Share Posted January 27, 2010 is the SELECT query being performed before the INSERT query on the same PHP page? does simply reloading the page without posting a new comment force the newest comment to be displayed? if not, have you checked what data your tables contain? Refreshed the page endless times, no result. The database sees the value, but it just doesn't work. See it for yourself: http://melkwegstelsel.co.cc/?p=gastenboek You're free to register. (Password is encoded ). Quote Link to comment https://forums.phpfreaks.com/topic/190037-not-all-values-from-mysql/#findComment-1002646 Share on other sites More sharing options...
akitchin Posted January 27, 2010 Share Posted January 27, 2010 it doesn't help to see the page if i don't know what's in the database... try posting the entire page and we'll see if we can't spot something that's wrong elsewhere, because at the moment, i can't see any issues. i would guess it's something in the if() block you've got leading up to the data echoes. Quote Link to comment https://forums.phpfreaks.com/topic/190037-not-all-values-from-mysql/#findComment-1002655 Share on other sites More sharing options...
NLCJ Posted January 27, 2010 Author Share Posted January 27, 2010 it doesn't help to see the page if i don't know what's in the database... try posting the entire page and we'll see if we can't spot something that's wrong elsewhere, because at the moment, i can't see any issues. i would guess it's something in the if() block you've got leading up to the data echoes. Since I was trying to get all the commands in one page it is over 600 lines at this moment... Is gonna be a bit hard. I can remember I had this problem before, with the menu since that one is also dynamic. I cannot remember how I solved that (it was the day before yesterday ). EDIT: I've added the file. At line 567 starts the part of the guestbook. At line 238 is the part where it inserts the values if you're registered. At line 251 starts the part when you're not registered. [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/190037-not-all-values-from-mysql/#findComment-1002656 Share on other sites More sharing options...
akitchin Posted January 27, 2010 Share Posted January 27, 2010 this is the problem: $d_berichten = mysql_fetch_array($d_getberichten); you're moving the resource ID one position forward when you use mysql_fetch_array() the first time. that means when you go to run your while() loop later, it starts one record late. if you don't necessarily need that first row, you can delete this line to avoid moving the counter forward. otherwise, use mysql_data_seek to reset the pointer to 0 before looping through when displaying the entries. Quote Link to comment https://forums.phpfreaks.com/topic/190037-not-all-values-from-mysql/#findComment-1002662 Share on other sites More sharing options...
NLCJ Posted January 27, 2010 Author Share Posted January 27, 2010 Thank you very much! It was useless over there, just forgot to delete it after I defined it in the while function. Quote Link to comment https://forums.phpfreaks.com/topic/190037-not-all-values-from-mysql/#findComment-1002664 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.