Jump to content

Not all values from MySQL


NLCJ

Recommended Posts

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.

Link to comment
Share on other sites

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)."')");

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 ;)).

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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  :confused:).

 

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]

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.