1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Call Username from DB by userID

Discussion in 'Databases' started by epic1231, Jul 29, 2009.

  1. #1
    Hey everyone, I am having trouble getting this to show up for some reason.. I've been able to do it with other things, but I am looking to have a username show up for users that is stored in a database..

    Here is my table structure for the username

    
    CREATE TABLE IF NOT EXISTS `cu_username` (
      `usernameId` int(10) NOT NULL auto_increment,
      `usernameUserid` int(30) NOT NULL default '0',
      `usernameTitle` text NOT NULL,
      PRIMARY KEY  (`usernameId`)
    ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=82 ;
    
    Code (markup):
    When a user signs into the game their userID is stored along with the usernameTitle (this is what I would like displayed)

    Any suggestions on how to do this?

    I thought it would be something like this (but can't figure out how to make sure the right username comes out with the right ID and the output code)

    
    $res = query("SELECT COUNT(*) FROM `cu_username` WHERE `usernameTitle`!=$user");
    
    Code (markup):
    Thanks in advance!
    -Bill
     
    epic1231, Jul 29, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    $res = query("SELECT COUNT(*) FROM `cu_username` WHERE `usernameTitle`!=$user");

    You need single quotes around $user.

    $res = query("SELECT COUNT(*) FROM `cu_username` WHERE `usernameTitle`!='$user'");
     
    jestep, Jul 29, 2009 IP
    epic1231 likes this.
  3. epic1231

    epic1231 Peon

    Messages:
    680
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ah damn something so simple!! Thank You Very Much

    Now to call it all I would have to enter is simply '.$usernameTitle.' correct?
     
    Last edited: Jul 29, 2009
    epic1231, Jul 29, 2009 IP