seany123 Posted October 6, 2008 Share Posted October 6, 2008 Basically for a game im making theres a home page which shows the players name... The name is a link to the players profile.php page. ive given it a try here but cant seem to get it working. <td width="90" bgcolor="#000000" class="style5"><strong>Name</strong></td> <td width="10" bgcolor="#000000" class="style5"> </td> <td width="176" bgcolor="#000000" class="style5"><a href=\"profile.php?id=" . $member['username'] .class="style7"><?=$player->username?> </a></td> profile.php?id=admin is the link to "my" players profile... but it for other it will still only link to my profile. Quote Link to comment Share on other sites More sharing options...
trecool999 Posted October 6, 2008 Share Posted October 6, 2008 It would be more help if we had the profile.php code instead. Quote Link to comment Share on other sites More sharing options...
seany123 Posted October 6, 2008 Author Share Posted October 6, 2008 <?php include("lib.php"); define("PAGENAME", "Profile"); $player = check_user($secret_key, $db); //Check for user ID if (!$_GET['id']) { header("Location: members.php"); } else { $query = $db->execute("select `id`, `username`, `registered`, `level`, `kills`, `deaths`, `hp` from `players` where `username`=?", array($_GET['id'])); if ($query->recordcount() == 0) { header("Location: members.php"); } else { $profile = $query->fetchrow(); } } include("templates/private_header.php"); ?> <fieldset> <legend><?=$profile['username']?>'s Profile</legend> <table width="90%"> <tr> <td width="50%">Username:</td> <td width="50%"><?=$profile['username']?> (<a href="mail.php?act=compose&to=<?=$profile['username']?>">Mail</a>)</td> </tr> <?=$profile['style']?> <tr> <td>Level:</td> <td><?=$profile['level']?></td> </tr> <tr><td></td></tr> <tr> <td>Status:</td> <td><font color="<?=($profile['hp']==0)?"red\">Dead":"green\">Alive"?></font></td> </tr> <tr> <td>Kills:</td> <td><?=$profile['kills']?></td> </tr> <tr> <td>Deaths:</td> <td><?=$profile['deaths']?></td> </tr> <tr><td></td></tr> <tr> <td>Registered:</td> <td><?=date("F j, Y, g:i a", $profile['registered'])?></td> </tr> <tr> <td>In-Game Age:</td> <?php $diff = time() - $profile['registered']; $age = intval(($diff / 3600) / 24); ?> <td><?=$age?> days</td> </tr> <tr> <td>Gender:</td> <td><?=$profile['gender']?></td> </tr> </table> <br /><br /> <center> <a href="battle.php?act=attack&username=<?=$profile['username']?>">Battle</a> <a href="mugging.php?act=mugging&username=<?=$profile['username']?>">Mug</a> </center> </fieldset> <?php include("templates/private_footer.php"); ?> Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 6, 2008 Share Posted October 6, 2008 It looks like in your first post you are mixing some php in with html. You have some quotes escaped, but its within regular html (from what you've posted anyway). Try: <td width="176" bgcolor="#000000" class="style5"><a href="profile.php?id="<?php echo $member['username']; ?>" class="style7"><?=$player->username?> </a></td> Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 6, 2008 Share Posted October 6, 2008 Also, if you want your code to be able to run on all servers, don't use short tags. Use the full php tag <?php Quote Link to comment Share on other sites More sharing options...
seany123 Posted October 6, 2008 Author Share Posted October 6, 2008 firstly... i tired the code you gave.. it just linked me to profile.php. so it didnt work, second what do you mean by all servers? Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 6, 2008 Share Posted October 6, 2008 Not all servers have short tags enabled, so it won't work on all servers, but <?php works everywhere. Ah, I left one of your original quotes in after profile.php?id=, try: <a href="profile.php?id=<?php echo $member['username']; ?>" class="style7"><?=$player->username?> </a> Quote Link to comment Share on other sites More sharing options...
seany123 Posted October 6, 2008 Author Share Posted October 6, 2008 the link is saying profile.php?id= because it doesn't finish off which id to go to, its just linking me still to profile.php Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 6, 2008 Share Posted October 6, 2008 that would mean $member['username'] is empty on your end. what happens if you <?php echo 'username='.$member['username']; ?> Quote Link to comment Share on other sites More sharing options...
seany123 Posted October 6, 2008 Author Share Posted October 6, 2008 just get: username= and nothing else Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 6, 2008 Share Posted October 6, 2008 It looks like you have an error, it seems $members should be $profile maybe (going by the 2nd post in the thread). try: $profile['username']; Quote Link to comment Share on other sites More sharing options...
seany123 Posted October 6, 2008 Author Share Posted October 6, 2008 Still taking me straight to Profile.php wow i never thought this would be so difficult. Quote Link to comment Share on other sites More sharing options...
seany123 Posted October 7, 2008 Author Share Posted October 7, 2008 anyone else have any ideas on how this could work? Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 7, 2008 Share Posted October 7, 2008 after this line: <?php $profile = $query->fetchrow(); add this and post the result: <?php echo "<pre>"; print_r($profile); echo "</pre>"; That will tell us if you are receiving your data. Quote Link to comment Share on other sites More sharing options...
seany123 Posted October 7, 2008 Author Share Posted October 7, 2008 add that in my profile.php? Quote Link to comment Share on other sites More sharing options...
CroNiX Posted October 7, 2008 Share Posted October 7, 2008 If that is the 2nd code you posted (with colored highlighting) yes. Quote Link to comment 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.