SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't get PHP/mySQL to display 1 result

    Hey all,

    I don't really ask for help that often but this time I really need it. I am running a query in my program and from the mysql> prompt I can run the query fine. When I try to run the query even in phpmyadmin it gets no result. The query and some code is

    PHP Code:

    $q2 
    "select ID from Weekly_Status where user_id = $userid LIMIT 1";
    $r2 mysql_query($r2);

    $array mysql_fetch_array($r2);

    $ID $array["$ID"];

    echo 
    $ID
    Of course my tables have all the required fields, I have also changed the variable "user_id = $userid" to "user_id = 5" which is should do. If anyone know why this happens please let me know.

    Regards,
    Paul

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well the reason is you assign the sql statement to $q2 but you query $r2
    PHP Code:
    $r2 mysql_query($r2); 
    should be
    PHP Code:
    $r2 mysql_query($q2); 
    And

    PHP Code:
    $ID $array["$ID"]; 

    Should be

    PHP Code:
    $ID $array["ID"]; 

    Without the dolalr sign since you are after the field ID
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Member
    Join Date
    Jan 2001
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks SO Much

    Sometimes I guess after working to 3AM in the morning and being a coding soldier sometimes hurts your eyes . That's for the advice and quick fix, I was just about ready to throw the monitor out the window.

    Thanks Again,
    Paul


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
  •