Davie33 Posted May 19, 2012 Share Posted May 19, 2012 hi i have beeen trying for awhile now to get this code working but with no joy. For after you make a comment username and avatar of the person that made the comment doesn't show. Can anyone help me on this thanks. <div id="center"> <div class="container_box1"> <div id="headergames2">Profile</div> <?php if(!isset($_SESSION["user"])) { echo '<center><span style="font-size:150%;text-align:center;">You must Register or log in to view member profiles.</span></center>'; } else { if(isset($_POST['addcomment'])) { if(empty($_POST['userid'])) { echo 'Sorry, the member you were commenting seems to be invalid.'; } elseif (empty($_POST['comment']) || empty($_POST['name'])) { echo 'Please go back and try again, it seems the comment or name was left empty.'; } else { $userid = yasDB_clean($_POST['userid']); $comment = yasDB_clean($_POST['comment'],true); $name = yasDB_clean($_POST['name']); $ipaddress = $_SERVER['REMOTE_ADDR']; yasDB_insert("INSERT INTO `memberscomments` (id,userid, comment, ipaddress, name) values ('', '{$userid}', '{$comment}', '{$ipaddress}', '{$name}')",false); echo '<span style="color:red;">Comment added!</span>'; } } $id = yasDB_clean($_GET['id']); $query = yasDB_select("SELECT * FROM `user` WHERE id = '$id'"); $row = $query->fetch_array(MYSQLI_ASSOC);$query->close(); $joined = date('m/d/y',$row['date']); $points = $row['plays']*50; if ( $row['website'] != '') { $website = '<a href="'.$row['website'].'" target="_blank">Website</a><br>'; } else { $website = 'No Website'; }; if ( $row['location'] != '') { $location = ''. $row['location'].'<br>'; } else { $location = 'Place where you stay.<br>'; }; if ( $row['job'] != '') { $occupation = ''. $row['job'].'<br>'; } else { $occupation = 'Work place.<br>'; }; if ( $row['useavatar'] == '1' ) { $avatarimage = $setting['siteurl'] . 'avatars/' . $row['avatarfile']; }else { $avatarimage = $setting['siteurl'] . 'avatars/useruploads/noavatar.JPG'; } if ($setting['seo'] == 'yes') { $membersprofile = $setting['siteurl'].'profile.html'; } else { $membersprofile = $setting['siteurl'].'index.php?act=profile'; } ?> <div class="containbox2"> <div class="profile"> <ul> <li class="title">Username: <?php echo $row['username'];?></li> <li class="profilepic"><img src="<?php echo $avatarimage;?>" width="130" height="100"> <br/> <a href="<?php echo $membersprofile;?>">Edit Profile</a> <hr><?php echo $website;?><hr> </li> </ul> <ul> <li class="title2">About Me</li> <li class="aboutme"><?php echo $row['aboutme'];?></li> </ul> </div> <div class="clear"></div> <div class="profile2"> <ul> <li class="info2">Location:</li> <li class="info2">Joined:</li> <li class="info2">Plays:</li> <li class="info2">Points:</li> <li class="info2">Occupation:</li> </ul> <ul> <li class="info"><?php echo $location;?></li> <li class="info"><?php echo $joined;?></li> <li class="info"><?php echo $row['plays'];?></li> <li class="info"><?php echo $points;?></li> <li class="info"><?php echo $occupation;?></li> </ul> <ul> <li class="info2">AIM:</li> <li class="info2">MSN:</li> <li class="info2">Skype:</li> <li class="info2">Yahoo:</li> </ul> <ul> <li class="info"><?php echo $row['aim'];?></li> <li class="info"><?php echo $row['msn'];?></li> <li class="info"><?php echo $row['skype'];?></li> <li class="info"><?php echo $row['yahoo'];?></li> </ul> </div> </div> <div class="clear"></div> </div> <div class="container_box1"><div id="headergames2">Member's Comments:</div> <div class="containbox2"> <div id="messages"> <?php $query = yasDB_select("SELECT * FROM memberscomments"); $query2 = yasDB_select("SELECT * FROM user"); $prefix = $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/smileys/'; if($query->num_rows == 0) { ?> <div class="container_box5">This member has no comments, be the first to add one!</div> <?php } else { $query = yasDB_select("SELECT *,DATE_FORMAT(`timestamp`,'%b %e, %y, %r') AS formatted_time FROM memberscomments WHERE `userid`=`id` ORDER BY `id` DESC LIMIT 5"); $row = $query->fetch_array(MYSQLI_ASSOC); $query2 = yasDB_select("SELECT `username`, `useavatar`, `avatarfile` FROM `user` WHERE `username` = '{$row['name']}'"); $row2 = $query2->fetch_array(MYSQLI_ASSOC); $text = $row['comment']; $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/biggrin.gif" title="biggrin" alt="biggrin" />',$text); $text = str_replace(':?','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/confused.gif" title="confused" alt="confused" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/cool.gif" title="cool" alt="cool" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/cry.gif" title="cry" alt="cry" />',$text); $text = str_replace(':shock:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/eek.gif" title="eek" alt="eek" />',$text); $text = str_replace(':evil:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/evil.gif" title="evil" alt="evil" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/lol.gif" title="lol" alt="lol" />',$text); $text = str_replace(':x','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/mad.gif" title="mad" alt="mad" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/razz.gif" title="razz" alt="razz" />',$text); $text = str_replace(':oops:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/redface.gif" title="redface" alt="redface" />',$text); $text = str_replace(':roll:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/rolleyes.gif" title="rolleyes" alt="rolleyes" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/sad.gif" title="sad" alt="sad" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/smile.gif" title="smile" alt="smile" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/surprised.gif" title="surprised" alt="surprised" />',$text); $text = str_replace(':twisted:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/twisted.gif" title="twisted" alt="twisted" />',$text); $text = str_replace(':wink:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/wink.gif" title="wink" alt="wink" />',$text); if ($setting['seo']=='yes') { $memberlink = $setting['siteurl'].'showmember/'.$id.'.html'; } else { $memberlink = $setting['siteurl'] . 'index.php?act=showmember&id='.$id; } if ( $row2['useavatar'] == '1' ) { $avatarimage = $setting['siteurl'] . 'avatars/' . $row2['avatarfile']; } else { $avatarimage = $setting['siteurl'] . 'avatars/useruploads/noavatar.jpg'; } ?> <div class="profile"> <ul> <li class="title">Username - <a href="<?php echo $memberlink;?>"><?php echo $row['name'];?></a></li> <li class="profilepic"><a href="<?php echo $memberlink;?>"><img src="<?php echo $avatarimage;?>" width="130" height="100"></a> </li> </ul> <ul> <li class="title2"><?php echo $row['timestamp'];?></li> <li class="aboutme"><?php echo $text;?></li> </ul> </div> <div class="clear"></div> <?php } ?> </div> <div class="clear"></div> </div> <div class="clear"></div> </div> <div class="container_box1"><div id="headergames2">Leave a comment:</div> <div class="containbox"> <center><div id="preview"></div></center> <div id="commentBox"> <center> <form name="addcomment" id="addcomment" method="post" action=""><strong>Message:</strong><br /> <div id="smiles"><center> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/biggrin.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :? ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/confused.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/cool.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/cry.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :shock: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/eek.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :evil: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/evil.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/lol.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :x ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/mad.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/razz.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :oops: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/redface.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :roll: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/rolleyes.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/sad.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/smile.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/surprised.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :twisted: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/twisted.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :wink: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/wink.gif';?>" border="0" /></a> </center></div> <textarea name="comment" rows="10" cols="60" id="comment_message"></textarea> <br /> <input type="hidden" name="timestamp" id="timestamp" value="<?php echo time(); ?>" /><br/> </center> <center> <input name="name" type="hidden" value="<?php echo $_SESSION['user'];?>" /><br /> <input type="hidden" name="recaptcha" id="recaptcha" value="no"> <input type="hidden" name="security" id="security" value="10"> <input type="hidden" name="member" value="yes"> <input type="hidden" name="userid" id="userid" value="<?php echo $id; ?>"> <input name="addcomment" type="submit" value="Add Comment" style="border: 1px solid #000; margin-top: 2px;" /><br/><br/> </form></center></div></div> <div class="clear"></div> <?php } ?> </div> Ps: sry for the long code. Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/ Share on other sites More sharing options...
trq Posted May 19, 2012 Share Posted May 19, 2012 You might want to narrow your problem down somewhat. Saying sorry for posting too much code just means that you yourself are aware you have posted too much code. Fix it. Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/#findComment-1346761 Share on other sites More sharing options...
Davie33 Posted May 19, 2012 Author Share Posted May 19, 2012 Here it is in 3 parts. This part here will show the members info about there self. Not sure if i need to update anything on this part. <div id="center"> <div class="container_box1"> <div id="headergames2">Profile</div> <?php if(!isset($_SESSION["user"])) { echo '<center><span style="font-size:150%;text-align:center;">You must Register or log in to view member profiles.</span></center>'; } else { if(isset($_POST['addcomment'])) { if(empty($_POST['userid'])) { echo 'Sorry, the member you were commenting seems to be invalid.'; } elseif (empty($_POST['comment']) || empty($_POST['name'])) { echo 'Please go back and try again, it seems the comment or name was left empty.'; } else { $userid = yasDB_clean($_POST['userid']); $comment = yasDB_clean($_POST['comment'],true); $name = yasDB_clean($_POST['name']); $ipaddress = $_SERVER['REMOTE_ADDR']; yasDB_insert("INSERT INTO `memberscomments` (id,userid, comment, ipaddress, name) values ('', '{$userid}', '{$comment}', '{$ipaddress}', '{$name}')",false); echo '<span style="color:red;">Comment added!</span>'; } } $id = yasDB_clean($_GET['id']); $query = yasDB_select("SELECT * FROM `user` WHERE id = '$id'"); $row = $query->fetch_array(MYSQLI_ASSOC);$query->close(); $joined = date('m/d/y',$row['date']); $points = $row['plays']*50; if ( $row['website'] != '') { $website = '<a href="'.$row['website'].'" target="_blank">Website</a><br>'; } else { $website = 'No Website'; }; if ( $row['location'] != '') { $location = ''. $row['location'].'<br>'; } else { $location = 'Place where you stay.<br>'; }; if ( $row['job'] != '') { $occupation = ''. $row['job'].'<br>'; } else { $occupation = 'Work place.<br>'; }; if ( $row['useavatar'] == '1' ) { $avatarimage = $setting['siteurl'] . 'avatars/' . $row['avatarfile']; }else { $avatarimage = $setting['siteurl'] . 'avatars/useruploads/noavatar.JPG'; } if ($setting['seo'] == 'yes') { $membersprofile = $setting['siteurl'].'profile.html'; } else { $membersprofile = $setting['siteurl'].'index.php?act=profile'; } ?> <div class="containbox2"> <div class="profile"> <ul> <li class="title">Username: <?php echo $row['username'];?></li> <li class="profilepic"><img src="<?php echo $avatarimage;?>" width="130" height="100"> <br/> <a href="<?php echo $membersprofile;?>">Edit Profile</a> <hr><?php echo $website;?><hr> </li> </ul> <ul> <li class="title2">About Me</li> <li class="aboutme"><?php echo $row['aboutme'];?></li> </ul> </div> <div class="clear"></div> <div class="profile2"> <ul> <li class="info2">Location:</li> <li class="info2">Joined:</li> <li class="info2">Plays:</li> <li class="info2">Points:</li> <li class="info2">Occupation:</li> </ul> <ul> <li class="info"><?php echo $location;?></li> <li class="info"><?php echo $joined;?></li> <li class="info"><?php echo $row['plays'];?></li> <li class="info"><?php echo $points;?></li> <li class="info"><?php echo $occupation;?></li> </ul> <ul> <li class="info2">AIM:</li> <li class="info2">MSN:</li> <li class="info2">Skype:</li> <li class="info2">Yahoo:</li> </ul> <ul> <li class="info"><?php echo $row['aim'];?></li> <li class="info"><?php echo $row['msn'];?></li> <li class="info"><?php echo $row['skype'];?></li> <li class="info"><?php echo $row['yahoo'];?></li> </ul> </div> </div> <div class="clear"></div> </div> part 2 This is after one members makes a comment no username or avatar shows this part here is the main part i need sorted <div class="container_box1"><div id="headergames2">Member's Comments:</div> <div class="containbox2"> <div id="messages"> <?php $query = yasDB_select("SELECT * FROM memberscomments"); $query2 = yasDB_select("SELECT * FROM user"); $prefix = $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/smileys/'; if($query->num_rows == 0) { ?> <div class="container_box5">This member has no comments, be the first to add one!</div> <?php } else { $query = yasDB_select("SELECT *,DATE_FORMAT(`timestamp`,'%b %e, %y, %r') AS formatted_time FROM memberscomments WHERE `userid`=`id` ORDER BY `id` DESC LIMIT 5"); $row = $query->fetch_array(MYSQLI_ASSOC); $query2 = yasDB_select("SELECT `username`, `useavatar`, `avatarfile` FROM `user` WHERE `username` = '{$row['name']}'"); $row2 = $query2->fetch_array(MYSQLI_ASSOC); $text = $row['comment']; $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/biggrin.gif" title="biggrin" alt="biggrin" />',$text); $text = str_replace(':?','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/confused.gif" title="confused" alt="confused" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/cool.gif" title="cool" alt="cool" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/cry.gif" title="cry" alt="cry" />',$text); $text = str_replace(':shock:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/eek.gif" title="eek" alt="eek" />',$text); $text = str_replace(':evil:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/evil.gif" title="evil" alt="evil" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/lol.gif" title="lol" alt="lol" />',$text); $text = str_replace(':x','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/mad.gif" title="mad" alt="mad" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/razz.gif" title="razz" alt="razz" />',$text); $text = str_replace(':oops:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/redface.gif" title="redface" alt="redface" />',$text); $text = str_replace(':roll:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/rolleyes.gif" title="rolleyes" alt="rolleyes" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/sad.gif" title="sad" alt="sad" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/smile.gif" title="smile" alt="smile" />',$text); $text = str_replace('','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/surprised.gif" title="surprised" alt="surprised" />',$text); $text = str_replace(':twisted:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/twisted.gif" title="twisted" alt="twisted" />',$text); $text = str_replace(':wink:','<img src="' . $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/wink.gif" title="wink" alt="wink" />',$text); if ($setting['seo']=='yes') { $memberlink = $setting['siteurl'].'showmember/'.$id.'.html'; } else { $memberlink = $setting['siteurl'] . 'index.php?act=showmember&id='.$id; } if ( $row2['useavatar'] == '1' ) { $avatarimage = $setting['siteurl'] . 'avatars/' . $row2['avatarfile']; } else { $avatarimage = $setting['siteurl'] . 'avatars/useruploads/noavatar.jpg'; } ?> <div class="profile"> <ul> <li class="title">Username - <a href="<?php echo $memberlink;?>"><?php echo $row['name'];?></a></li> <li class="profilepic"><a href="<?php echo $memberlink;?>"><img src="<?php echo $avatarimage;?>" width="130" height="100"></a> </li> </ul> <ul> <li class="title2"><?php echo $row['timestamp'];?></li> <li class="aboutme"><?php echo $text;?></li> </ul> </div> <div class="clear"></div> <?php } ?> </div> <div class="clear"></div> </div> <div class="clear"></div> </div> part 3 Here is where you enter comment which i don't think needs fixed <div class="container_box1"><div id="headergames2">Leave a comment:</div> <div class="containbox"> <center><div id="preview"></div></center> <div id="commentBox"> <center> <form name="addcomment" id="addcomment" method="post" action=""><strong>Message:</strong><br /> <div id="smiles"><center> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/biggrin.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :? ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/confused.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/cool.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/cry.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :shock: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/eek.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :evil: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/evil.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/lol.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :x ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/mad.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/razz.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :oops: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/redface.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :roll: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/rolleyes.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/sad.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/smile.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/surprised.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :twisted: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/twisted.gif';?>" border="0" /></a> <a href="javascript:addsmilie(' :wink: ')"><img src="<?php echo $setting['siteurl'].'templates/'.$setting['theme'].'/skins/'.$setting['skin'].'/images/smileys/wink.gif';?>" border="0" /></a> </center></div> <textarea name="comment" rows="10" cols="60" id="comment_message"></textarea> <br /> <input type="hidden" name="timestamp" id="timestamp" value="<?php echo time(); ?>" /><br/> </center> <center> <input name="name" type="hidden" value="<?php echo $_SESSION['user'];?>" /><br /> <input type="hidden" name="recaptcha" id="recaptcha" value="no"> <input type="hidden" name="security" id="security" value="10"> <input type="hidden" name="member" value="yes"> <input type="hidden" name="userid" id="userid" value="<?php echo $id; ?>"> <input name="addcomment" type="submit" value="Add Comment" style="border: 1px solid #000; margin-top: 2px;" /><br/><br/> </form></center></div></div> <div class="clear"></div> <?php } ?> </div> Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/#findComment-1346763 Share on other sites More sharing options...
Davie33 Posted May 19, 2012 Author Share Posted May 19, 2012 Can i join these two query's together ? $query = yasDB_select("SELECT * FROM memberscomments"); $query2 = yasDB_select("SELECT * FROM user"); //and this one too $query = yasDB_select("SELECT *,DATE_FORMAT(`timestamp`,'%b %e, %y, %r') AS formatted_time FROM memberscomments WHERE `userid`=`id` ORDER BY `id` DESC LIMIT 5"); $query2 = yasDB_select("SELECT `username`, `useavatar`, `avatarfile` FROM `user` WHERE `username` = '{$row['name']}'"); and if so how is this done so am not doing it like query and query2 ?. <?php $query = yasDB_select("SELECT * FROM memberscomments"); $query2 = yasDB_select("SELECT * FROM user"); $prefix = $setting['siteurl'] . 'templates/' . $setting['theme'] . '/skins/' . $setting['skin'] . '/images/smileys/'; if($query->num_rows == 0) { ?> <div class="container_box5">This member has no comments, be the first to add one!</div> <?php } else { $query = yasDB_select("SELECT *,DATE_FORMAT(`timestamp`,'%b %e, %y, %r') AS formatted_time FROM memberscomments WHERE `userid`=`id` ORDER BY `id` DESC LIMIT 5"); $row = $query->fetch_array(MYSQLI_ASSOC); $query2 = yasDB_select("SELECT `username`, `useavatar`, `avatarfile` FROM `user` WHERE `username` = '{$row['name']}'"); $row2 = $query2->fetch_array(MYSQLI_ASSOC); Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/#findComment-1346777 Share on other sites More sharing options...
Davie33 Posted May 19, 2012 Author Share Posted May 19, 2012 Hi done the first part of the query like so and no error so far. $query = yasDB_select("SELECT * FROM memberscomments JOIN user;"); I can't think how to do the other one i have tryed a few thing but none work so far. here is one example. $query = yasDB_select("SELECT *,DATE_FORMAT(`timestamp`,'%b %e, %y, %r') AS formatted_time FROM memberscomments WHERE `userid`=`id` JOIN `username`, `useavatar`, `avatarfile` FROM `user` WHERE `username` = '{$row['name']}' ORDER BY `id` DESC LIMIT 5;"); Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/#findComment-1346779 Share on other sites More sharing options...
trq Posted May 19, 2012 Share Posted May 19, 2012 That first query is not going to help. We need to see your table schemas. Your selecting * which again does not help. Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/#findComment-1346781 Share on other sites More sharing options...
Davie33 Posted May 19, 2012 Author Share Posted May 19, 2012 Here is sql for both tables user table CREATE TABLE IF NOT EXISTS `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL, `password` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL, `name` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `useavatar` tinyint(1) NOT NULL DEFAULT '0', `avatarfile` varchar(75) COLLATE utf8_unicode_ci NOT NULL, `email` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `plays` int(11) NOT NULL DEFAULT '0', `date` int(10) NOT NULL DEFAULT '0', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ; memberscomments table CREATE TABLE IF NOT EXISTS `memberscomments` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `userid` int(11) NOT NULL, `ipaddress` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `comment` text COLLATE utf8_unicode_ci NOT NULL, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '', `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `name` (`name`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=21 ; Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/#findComment-1346782 Share on other sites More sharing options...
trq Posted May 19, 2012 Share Posted May 19, 2012 Ok, so your first join will want to join users to there comments. SELECT u.name, c.comment FROM users u LEFT JOIN memberscomments c ON (u.id = c.userid) I have aliased the user table to u and the memberscomments table to c. This should give you a pretty easy example of how joins are done. Now, why do you have two name fields? Also, don't use SELECT *, you should specify the fields you want. Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/#findComment-1346783 Share on other sites More sharing options...
trq Posted May 19, 2012 Share Posted May 19, 2012 Oh, and your other one. SELECT u.name, u.useavatar, u.avatarfile, DATE_FORMAT(`timestamp`,'%b %e, %y, %r') AS formatted_time FROM user u LEFT JOIN memberscomments c ON (u.id = c.userid) ORDER BY `timestamp` DESC LIMIT 5 You don't really need toi use aliases unless two fields are going to conflict. Also, I would avoid naming fileds using reserved words like date and timestamp, this way you don't need all those ugly backticks. Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/#findComment-1346785 Share on other sites More sharing options...
Davie33 Posted May 19, 2012 Author Share Posted May 19, 2012 Now, why do you have two name fields? Also, don't use SELECT *, you should specify the fields you want. How do i do that without select ? To what you done for sql is giving out error on line 114 which is this $text = $row['comment']; from this error. Notice: Undefined index: comment in C:\wamp\www\name\templates\name\showmember.php on line 114 Plus from your 2nd sql is giving out error for timestamp. Notice: Undefined index: timestamp in C:\wamp\www\name\templates\name\showmember.php on line 149 which is this <li class="title2"><?php echo $row['timestamp'];?></li> Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/#findComment-1346881 Share on other sites More sharing options...
Davie33 Posted May 19, 2012 Author Share Posted May 19, 2012 Now, why do you have two name fields? Thanks for pointing that out i have changed u.name to u.username now username shows as well as avatars just need to get them two errors sorted. Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/#findComment-1346885 Share on other sites More sharing options...
Davie33 Posted May 20, 2012 Author Share Posted May 20, 2012 Hi i fixed the errors i had but only one comment show's and even at that the wrong avatar and username shows different when am logged in. What i mean is when user test logged in and i make a comment on test2 profile test2 name and avatar shows instead of test Quote Link to comment https://forums.phpfreaks.com/topic/262762-username-and-avatars-not-showing/#findComment-1346936 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.