...

View Full Version : help with select statement?



angst
07-08-2005, 04:30 PM
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

angst
07-08-2005, 04:37 PM
oh, nevermind, i've figured it out:-P

-Ken

joeframbach
07-08-2005, 04:47 PM
just for the record, what was the solution?
single quotes don't interpolate variables. was that it?

angst
07-08-2005, 04:49 PM
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;-)

joeframbach
07-08-2005, 05:07 PM
mySql likes to have backticks for table and column names.

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum