Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Apr 2009
    Posts
    23
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Simple SQL Query D'OH

    I feel like such a dumb a** but I can't figure out how to pull one value from a database and I have searched and searched and can't find it because it is too simple and everyone knows how to do it so why put it on the internet lol. I know it is is something stupid and I just am not seeing it but here is my code:

    $result = mysql_query("SELECT name FROM si_customers WHERE id='$_SESSION[user_id]'");
    $customer_name = mysql_query($result);

    I have verified that my sql statement works in phpmyadmin
    I have verified that there is an actual value in $_SESSION[user_id]
    I have verified the table name and the column names name and id
    so I gotta be doing something dumb

    Please help

  • #2
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Code:
    $result = mysql_query("SELECT name FROM si_customers WHERE id='$_SESSION[user_id]'");
    $customer_name = mysql_result($result);

  • #3
    New Coder
    Join Date
    Apr 2009
    Posts
    23
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Hmm, I got an error with that:

    Warning: Wrong parameter count for mysql_result()

  • #4
    Senior Coder
    Join Date
    Jul 2009
    Location
    South Yorkshire, England
    Posts
    2,318
    Thanks
    6
    Thanked 304 Times in 303 Posts
    Code:
    $customer_name = mysql_result($result, 0);

  • Users who have thanked MattF for this post:

    countrygirl (04-01-2010)

  • #5
    New Coder
    Join Date
    Apr 2009
    Posts
    23
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Thank you Matt, that was the ticket


  •  

    Posting Permissions

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