Jump to content

Recommended Posts

hi,

 

my mysql connects to the db fine and then selects the right row. Then when it gets to echo section, it prints the first column/value which is ID. Heres mysql table structure.

 

ID                   USERNAME                    PASSWORD                   EMAIL                RACE            HEALTH <----- this is one i want
1                    dsfasdfsdf               
2                    ..............                     
3
4
..

 

 

Here is the code for stats.php:

 

<?php

$host="sql2.ifastnet.com"; // Host name.
$db_user="::you can't know! XD::"; // MySQL username.
$db_password="::you can't know! XD::"; // MySQL password.
$database="rpgnow_"; // Database name.
mysql_connect($host,$db_user,$db_password);
mysql_select_db($database);

$query = "SELECT * FROM rpgusers WHERE username =  '" . $_SESSION["username"] . "'";;
$result = mysql_query($query);
echo "<font color='ff0000' size='1' face='verdana'>Health = $result</font>";

?>

 

After i login as admin ( who has the user id of 3 =] )and click on status page link it says:

Health = Resource id #3

 

please help...

Link to comment
https://forums.phpfreaks.com/topic/39343-wrong-mysql-valuecolumn-being-selected/
Share on other sites

<?php
mysql_connect("host","user","password");
mysql_select_db("database");
$query = "SELECT * FROM rpgusers WHERE username =  '" . $_SESSION["username"] . "'";;
$result = mysql_query($query);
while($row = mysql_fetch_array($result))
{
echo "<font color='ff0000' size='1' face='verdana'>Health = $row['Health']</font>";
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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