SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Jul 2000
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,
    I am currently programming a guestbook hosting script, which is in its very early stages.
    I am experiencing a strange problem when printing each entry.
    What happens is, when each entry is printed, the first one is fine, but from then on, all the 'visitor details' are printed continuously.
    For example, say the first entry in the guestbook is:
    name: AJ
    email: AJ@whatever.com
    message: hello.
    Yahoo IM: whatever@yahoo.com
    (the rest of the fields aren't filled in)

    This prints fine. However, on the next entry, say it is:
    name: AJ2
    email: AJ2@whatever.com
    homepage: http://www.whatever.com
    icq : 9784537

    the next entry also shows the previous entrys 'user details'.
    So the second entry shows:

    name: AJ2
    email: AJ@whatever.com
    email: AJ2@whatever.com
    homepage: http://www.whatever.com
    icq : 9784537
    Yahoo IM: whatever@yahoo.com

    See what I mean? It shows teh previous entries details (although not the name, postdate, posttime or message).

    So obviously, with tens of entries, the last one ends up having all the previous peoples details on them...
    Can anyone help me with this?
    The snippet of the faulty code is shown below.

    Code:
    //before this is a count query, and an include
    	if ($total < 1) {
    		echo "<center><font class=userfont><big><b>Sorry, there are no messages in this guestbook</b></big></font>
    			<br><font class=userfont><small>Be the first to <a href=sign.gb?user=$user>Sign this guestbook</a>!</small></font></center>";
    	} else {
    
    	/*GET ENTRIES*/
    
    		$posts = mysql_query("SELECT * FROM posts WHERE uid='$user' ORDER BY postdate DESC LIMIT $limit2, $limit");
    
    		while ($detail = mysql_fetch_array($posts)) {
    		
    			$pid = $detail["pid"];
    			$postdate = $detail["postdate"];
    			$posttime = $detail["posttime"];
    			$visitorip = $detail["visitorip"];
    			$name = $detail["name"];
    			$email = $detail["email"];
    			$homepage = $detail["homepage"];
    			$input1 = $detail["input1"];
    			$input2 = $detail["input2"];
    			$input3 = $detail["input3"];
    			$input4 = $detail["input4"];
    			$input5 = $detail["input5"];
    			$icq = $detail["icq"];
    			$aim = $detail["aim"];
    			$msn = $detail["msn"];
    			$yahoo = $detail["yahoo"];
    			$message = $detail["message"];
    			$private = $detail["private"];
    
    ?>
    
    <!-- <?=$gbentry?> - <?=$pid?> -->
    <center>
    <table width=80% border=0 cellspacing=1 cellpadding=2 bgcolor=000000><tr bgcolor=ffffff><td>
    
    <?
    
    				
    			echo("	<table width=100%><tr bgcolor=eeeeee><td width=25%><font class=v7>$postdate, $posttime</font></td>
    				<td width=75% align=right><font class=userfont><b>$name</b>&nbsp;&nbsp;</font>"); 
    					
    				
    			/*CHECK WHETHER OR NOT TO PRINT VISITOR DETAILS ($vd)*/
    			if ($email) {
    				if ($userharvprotect == 'y') {
    					$email = str_replace("@", "_at_", $email);
    					$vd[] = "<a href='mail.gb?user=$user&email=$email' title='send an email to this person'><img src=images/email.gif border=0></a>";
    				} else {
    					$vd[] = "<a href='mailto:$email'  title='send this person an email'><img src=images/email.gif border=0></a>";
    				}	
    			}
    				
    			if ($homepage) {
    				$vd[] = "<a href='$homepage'  title='visit this persons homepage'><img src=images/home.gif border=0></a>";
    			}
    				
    			if ($icq) {
    				$vd[] = "<a href='http://wwp.icq.com/$icq'  title='contact this person on ICQ'><img src=images/icqo.gif border=0></a>";
    			}
    				
    			if ($aim) {
    				$vd[] = "<a href='aim:goim?screenname=$aim&message=Hi+$aim.+Are+you+there?' title='contact this person on Aol Instant Messenger'><img src=images/aim.gif border=0></a>";
    			}
    
    			if ($msn) {
    				$vd[] = "<a href='http://profiles.msn.com/$msn' title='contact this person on MSN Messenger'><img src=images/msnm.gif border=0></a>";
    			}
    
    			if ($yahoo) {
    				$vd[] = "<a href='http://edit.yahoo.com/config/send_webmesg?.target=$yahoo' title='contact this person on Yahoo Messenger'><img src=images/yim.gif border=0></a>";
    			}
    
    			if(!$vd) {  /*IF NO VISITOR DETAILS*/
    			echo("</font></td></tr></table>");
    			} else {
    				/*PRINT VISITOR DETAILS*/
    				for ($j=0;$j < count($vd);$j++) { 
    				print $vd[$j];
    				print "<img src=images/spacer.gif width=6 height=1>";
    				} //end for statement
    			
    			echo("</font></td></tr></table>");
    			}				
    				
    			if ($userallowsmilies == 'y') {
    				//t2s($message);
    			}
    				
    			if ($usergbcensorship == 'y') {
    				//censorship($name);
    				//censorship($message);
    				//censorship($homepage);
    			
    			}
    				
    			if ($userallowhtml == 'y') {
    			} else {
    			}
    
    				
    			if ($private == 'y') {
    				echo("<center><br><font class=userfont>This is a private message.<br>Admin, <a href=adminlogin.php>Login</a> to read.<br><br></center>");
    			} else { 
    				echo("<img src=spacer.gif width=5 height=5><br><table width=100%><tr><td><font class=userfont>$message</font></td></tr></table>");
    				//<table width=100%><tr align=left valign=top><td width=33%><font class=a10b>Input 1</font></td><td width=67%><font class=a10>Input 1 answer Input 1 answer</font></td></tr></table>	
    			} 
    		
    			echo("</td></tr></table></center><Br>\n<!-- end $gbentry - $pid -->\n");
    		} /*END WHILE*/
    		
    	}
    Cheers.

    -AJ

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2001
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how about giving $vd[] indeces for each assignment.

    ie

    $vd[1] = blah;
    $vd[2] = blah;

    for(j=0;j < count($vd); j++){

    blah

    }

    reset($vd);

    sorry about that.. wrong button the first time..

    hope that's an option.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •