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

    Join Date
    Apr 2000
    Posts
    14
    Rep Power
    0
    Hi,

    I want to do the following:

    Select ID
    From tablename
    where name='$name'

    How do I do this in PHP?

    Thanks in advance,
    Yomo
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    20
    Rep Power
    0
    $query = "SELECT * FROM table_name WHERE
    columnname="" .
    $variable_name . """;


    mysql_connect($host,$user,$password);
    mysql_select_db($database);
    $result = mysql_query($query);

  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 1999
    Location
    Ann Arbor, MI USA
    Posts
    6
    Rep Power
    0
    MySQL uses single quotes. Try:

    $Query = "select ID From tablename where name='$name'";

    Then the rest of what CTD said.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    20
    Rep Power
    0
    Darn, I have been using double quotes. I will say that they work, but I guess I should switch to the correct syntax.

Similar Threads

  1. How to create a csv type output via a select statement
    By jgabay in forum Oracle Development
    Replies: 3
    Last Post: February 28th, 2004, 06:23 AM
  2. putting a c++ int variable into an sql statement in C++
    By rorybreen1 in forum C Programming
    Replies: 3
    Last Post: February 16th, 2004, 08:58 PM
  3. Do I need to select a field in a SELECT statement?
    By assemblage in forum MySQL Help
    Replies: 7
    Last Post: February 12th, 2004, 09:34 PM
  4. PHP SQL select statement
    By rhythmicdevil in forum PHP Development
    Replies: 6
    Last Post: January 14th, 2004, 07:26 AM
  5. Replies: 5
    Last Post: January 11th, 2004, 09:19 PM

IMN logo majestic logo threadwatch logo seochat tools logo