#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Norcross, GA
    Posts
    458
    Rep Power
    14
    I'd like to use a variable in a SELECT statement, but I'm having trouble making it work.

    My query works fine if I hardcode search criteria:

    SELECT * FROM tablename WHERE brand="Honda"


    However, this returns a '0 is not a MySQL result' error:

    $brand="Honda"
    SELECT * FROM tablename WHERE brand=$brand


    What is the correct syntax to use?

    - Mike
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Washington, USA
    Posts
    52
    Rep Power
    14
    Like this:

    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre>
    $brand= "Honda";
    $query = "SELECT * FROM tablename WHERE brand='$brand'";
    [/code]

    ------------------
    <UL TYPE=SQUARE>
    <LI> TD Scripts
    <LI> Script School
    <LI>php-scripts
    </UL>

Similar Threads

  1. Passing POST variables
    By rlorenzo in forum PHP Development
    Replies: 11
    Last Post: June 6th, 2004, 02:00 PM
  2. Replies: 7
    Last Post: February 16th, 2004, 02:55 PM
  3. help with assigning variables, variable passing/ retrieval
    By pinkipodmini in forum PHP Development
    Replies: 0
    Last Post: February 13th, 2004, 09:40 PM
  4. Passing Values w/o specifying variables
    By spk921803 in forum PHP Development
    Replies: 5
    Last Post: February 9th, 2004, 10:35 PM
  5. php variables in java passing through the url
    By panahi in forum Java Help
    Replies: 0
    Last Post: January 23rd, 2004, 03:50 PM

IMN logo majestic logo threadwatch logo seochat tools logo