PHPDevil Posted December 26, 2012 Share Posted December 26, 2012 Hi again. Just having a mysqli issue. First time using databases and tables. I have a table with PlayerIDs and Username as the title. Table itself is called users When a person logs in i create a session variable for ID $_SESSION['ID'] = $id; Now in the game I want to retrieve that username so I'm able to display it. I don't want to use the session variable to do this as i will be reusing that username constantly so i would want it stored in a variable. $data = mysqli_query($mysqli, "SELECT * FROM userss WHERE PlayerIDs =" . $_SESSION['ID']); $info = mysqli_fetch_array( $data ); The above is my sql that im using. And to ouput the result I use echo $info['Username']; Yet nothing gets displayed. Is there a way where I can call all this data easily and display it easily. Like for example if i wanted to display there level aswell. So in other words control what is displayed? Thanks Quote Link to comment Share on other sites More sharing options...
Uridium Posted December 26, 2012 Share Posted December 26, 2012 does your users table has 2 s's >> userss ?? Quote Link to comment Share on other sites More sharing options...
AnonymousUser Posted December 26, 2012 Share Posted December 26, 2012 $data = mysqli_query($mysqli, "SELECT * FROM users WHERE PlayerIDs =" . $_SESSION['ID']); $info = mysqli_fetch_array( $data ); try that... Quote Link to comment Share on other sites More sharing options...
sniko Posted December 26, 2012 Share Posted December 26, 2012 Here's it OO style, which I find easier with mysqli $data = $mysqli->query("SELECT [...]"); $info = $data->fetch_array(MYSQLI_ASSOC); You'd have to slightly edit your config (connect to the database) 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.