SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    london
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    database question

    Hi i am trying to write a function that checks the users details and returns the id but i think i am stuck.
    function Login($username,$password)
    {
    $db_conn = ocilogon("scott", "tiger");
    $cmdstr = "SELECT member_id FROM Member WHERE member_username='" . $username . "' " .
    "AND member_password='" . $password . "'";
    $parsed = OCIParse($db_conn,$cmdstr);
    OCIExecute($parsed);
    $nrows = ocifetchstatement($parsed,$results);


    }

    i am new to php so i am a bit confused abt a few things
    1what does $results and $nrows contain.


    Thanks

  2. #2
    does not play well with others frezno's Avatar
    Join Date
    Jan 2003
    Location
    Munich, Germany
    Posts
    1,391
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $sql "SELECT member_id FROM Member WHERE member_username='"$username ."' AND member_password='"$password ."'";
     
    $r mysql_query($sql);
     
    if (
    mysql_num_rows($r) == 1)
    {
        echo 
    "Member ID = "$r['member_id'];

    We are the Borg. Resistance is futile. Prepare to be assimilated.
    I'm Pentium of Borg.Division is futile.Prepare to be approximated.

  3. #3
    <? james('rules'); ?>
    Join Date
    Jun 2004
    Location
    Wales, UK
    Posts
    788
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your code is wrong, but usually what you find with those variables, they are assigned to a certain thing in most tutorials.

    Mainly $result or $results will be assigned to a mysql_query(). Maybe a select or insert for example. $nrows would probably be found as $num_rows, $num, or $count (although this is usually used in loops). The variable name themselves mean nothing. They could be called $bob and $cheese. Its what function is assigned to them that matters.
    If knowledge is power - Why isn't our army librarians?!
    Statistics show that 63% of all statistics are fake.
    When i was little i broke my neck, and i havent looked back since .
    I completed the internet in 1 week. The end boss was pretty easy though .

  4. #4
    SitePoint Enthusiast
    Join Date
    Oct 2004
    Location
    london
    Posts
    45
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok so what would the correct code be, basically i want to write some code to accept username and password form a db and validate it. i am not using mysql , i am usin goracle and the oci functions...

    thanks


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •