Thread: User id

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    26
    Rep Power
    0
    Hello all,

    I have most of my application written, apart from one problem that seems to be nagging me. I have created a user table that contains a primary key (uid) and a login and password variables. I have also created several other tables that have a uid field. I would like to reference these tables by the users table.

    In order for me to do this I must be able to find out the uid of the person logging in. For testing purposes I want to print the uid. I have shown an extract of my code below. For some reason I always get the uid of 0 displayed. (I tend to think that this is the result of the query). Can someone please help.

    $result = mysql_query("select uid='$uid' from user where login='$login' and passw='$passw'");
    printf("user id: %s<br>n", mysql_result($result,"$uid"));


    Regard

    Richard
  2. #2
  3. .Net Developer
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2000
    Location
    London
    Posts
    987
    Rep Power
    15

    $result = mysql_query("select uid='$uid' from user where login='$login' and passw='$passw'");
    printf("user id: %s<br>n", mysql_result($result,"$uid"));



    Richard,
    just try the following example..

    <?
    $result = mysql_query("select uid as id from user where login='$login' and passw='$passw'");

    $row=mysql_fetch_array($result);

    echo "User ID:".$row["id"];
    ?>




    ------------------
    SR -
    webshiju.com

    "The fear of the LORD is the beginning of knowledge..."
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2000
    Posts
    26
    Rep Power
    0
    Thanks Shiju Rajan, for your help, that worked. I would also like to reference these tables by the users table uid. But the uid in the code that you have provided does not seem to store it as a variable. Something like that below is what Iam trying to achieve:

    <?
    $result = mysql_query("select news from headline where uid='$uid'");

    $row=mysql_fetch_array($result);

    ?>



    [This message has been edited by rway (edited July 22, 2000).]

Similar Threads

  1. Can user A read user B's session?
    By Stupid Khor in forum PHP Development
    Replies: 9
    Last Post: May 11th, 2004, 05:19 AM
  2. Stopping form submittion until user clicks Agree button
    By leemeisner in forum HTML Programming
    Replies: 2
    Last Post: April 13th, 2004, 10:46 AM
  3. php user levels
    By dynasty in forum PHP Development
    Replies: 1
    Last Post: January 20th, 2004, 02:01 PM
  4. How to get multiple sessions for one user working?
    By jkoerber in forum PHP Development
    Replies: 1
    Last Post: January 16th, 2004, 01:23 PM
  5. Is there a drop-in user control module?
    By Kent Wang in forum PHP Development
    Replies: 3
    Last Post: December 20th, 2003, 05:20 AM

IMN logo majestic logo threadwatch logo seochat tools logo