Jump to content

[SOLVED] how do i show users gold?


berry05

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/137462-solved-how-do-i-show-users-gold/
Share on other sites

<?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!";
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.