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
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts

    help with select statement?

    Hello,
    i'm trying to pass a variable into my select WHERE statement, but keep getting an error, i'm missing some syntax or something,

    error:

    Unknown column '$view' in 'where clause'

    code:

    ('SELECT * FROM picdata where PicSection= $view LIMIT 12 ')


    what am i doing wrong here?

    thanks for your time!
    -Ken

  • #2
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    oh, nevermind, i've figured it out:-P

    -Ken

  • #3
    Regular Coder
    Join Date
    Dec 2002
    Location
    a bit west of pittsburgh
    Posts
    236
    Thanks
    1
    Thanked 0 Times in 0 Posts
    just for the record, what was the solution?
    single quotes don't interpolate variables. was that it?

  • #4
    Senior Coder angst's Avatar
    Join Date
    Apr 2004
    Location
    Toronto, Ontario
    Posts
    2,114
    Thanks
    15
    Thanked 122 Times in 122 Posts
    yah, i just have to change it to:

    ("SELECT * FROM picdata where PicSection= '$view' LIMIT 12 ")

    with the double quotes for the whole statement, and then single quotes for the variable.

    i'm still learning;-)

  • #5
    Regular Coder
    Join Date
    Dec 2002
    Location
    a bit west of pittsburgh
    Posts
    236
    Thanks
    1
    Thanked 0 Times in 0 Posts

    pedantic

    mySql likes to have backticks for table and column names.

    "SELECT * FROM `picdata` where `PicSection`='$view' LIMIT 12"


  •  

    Posting Permissions

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