berry05 Posted December 18, 2008 Share Posted December 18, 2008 i have this code now.. <?php mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("textgame") or die(mysql_error()); $result = mysql_query("SELECT * FROM users WHERE username='$Username'") or die(mysql_error()); $row = mysql_fetch_array( $result ); echo $row['gold']; ?> to show the users gold but i get no errors and it doesnt show the gold though...when i get rid of usernames= $usernames thing it shows the gold for the first user in the row though.. plz help! thxs! Quote Link to comment https://forums.phpfreaks.com/topic/137462-solved-how-do-i-show-users-gold/ Share on other sites More sharing options...
.josh Posted December 18, 2008 Share Posted December 18, 2008 I don't see anywhere in that code where you are assigning anything to $Username Quote Link to comment https://forums.phpfreaks.com/topic/137462-solved-how-do-i-show-users-gold/#findComment-718352 Share on other sites More sharing options...
berry05 Posted December 18, 2008 Author Share Posted December 18, 2008 on the top of the whole script theres this.. <?php session_start(); if(isset($_SESSION['Username'])){ ?> if that would be it? Quote Link to comment https://forums.phpfreaks.com/topic/137462-solved-how-do-i-show-users-gold/#findComment-718363 Share on other sites More sharing options...
timmah1 Posted December 18, 2008 Share Posted December 18, 2008 $Username = $_SESSION['Username']; $result = mysql_query("SELECT * FROM users WHERE username='$Username'") Quote Link to comment https://forums.phpfreaks.com/topic/137462-solved-how-do-i-show-users-gold/#findComment-718367 Share on other sites More sharing options...
redarrow Posted December 18, 2008 Share Posted December 18, 2008 <?php session_start(); if(isset($_SESSION['Username'])){ $db=mysql_connect('localhost', 'root', 'password'); $res=mysql_select_db('textgame',$db) or die(mysql_error()); $sql = "SELECT * FROM users WHERE username='".$_SESSION['Username']."'"; $res=mysql_query($sql)or die(mysql_error()); while($row = mysql_fetch_assoc($res)){ echo $row['gold']; } }else{ echo "Sorry your not a member please join us!"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/137462-solved-how-do-i-show-users-gold/#findComment-718371 Share on other sites More sharing options...
berry05 Posted December 18, 2008 Author Share Posted December 18, 2008 thank you guys!! redarrow...what did you do to fix the problem? Quote Link to comment https://forums.phpfreaks.com/topic/137462-solved-how-do-i-show-users-gold/#findComment-718382 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.