So basically i have set up a login system and when you log in it displays "Welcome " and then ur username, i want to set up where it does a display name instead, so i have it all set up with the register system and stuff but i've ran into a small problem.
I wanted it to assign the display name in the database to a varialbe
First I tried this
$data = mysql_query("SELECT userid FROM ao_user WHERE username = '{$this->_username}' AND password = '{$this->_password}' AND display = '{$this->_display}'");
I don't know if i set that up correctly or not. Whenever i go to log in when this is set up it says invalid username/password, even though i know its right. So that makes me think that its because thats where it checks the database for the correct username and password and if i add that in since when the user logs in they dont have to type in a display name it does nothing. I could be wrong
But i decided to move on so i tried doing this
$displaynamedata = mysql_query("SELECT userid FROM ao_user WHERE display = " . $this->_display);
The login executes but then it displays nothing for the display name.
Sorry that im terrible at explaining but hopefully someone can understand what im doing!
Thanks in advanced
EDIT: I just realized this as well but i could be wrong again, i think im executing the query backwards? Im not sure and im really confused.
EDIT: Ok so i got a bit of a problem
I set up a different script and it worked, this is how the script looked
<?php
$username = "Nynex71";
mysql_connect("localhost", "root", "test") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
$result = mysql_query("SELECT display FROM ao_user WHERE username = '{$username}'") or die(msyql_error());
$row = mysql_fetch_assoc($result);
echo $row['display'];
?>
Then i tried merging it in with my system annndd nothing display after welcome
This is the code that was merged in
public function getDisplay()
{
mysql_connect("localhost", "root", "test") or die(mysql_error());
mysql_select_db("test") or die(mysql_error());
$result = mysql_query("SELECT display FROM ao_user WHERE username = '{$this->_username}'");
$row = mysql_fetch_assoc($result);
$this->_display = $row['display'];
$_SESSION['display'] = $this->_display;
}
I dont understand what could go wrong through that?