I am getting MYSQL Error and My 1uery is:
$SQL = "SELECT * FROM `".TBL_DEVICE."` WHERE DEV_STATUS='1' $where ORDER BY DEV_TYPE ASC";
Error is as follows
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY DEV_TYPE ASC' at line 1
SELECT * FROM `device` WHERE DEV_STATUS='1' AND DEV_ID = ORDER BY DEV_TYPE ASC
你还没有给 - DEV_ID 赋值
SELECT * FROM `device` WHERE DEV_STATUS='1' AND DEV_ID = '*add here*' ORDER BY DEV_TYPE ASC
Well, at least you printed it out, something most people don't do, and something that makes 97% of these problems obvious :-)
SELECT * FROM `device` WHERE DEV_STATUS='1' AND DEV_ID = ORDER BY ...
\__________/
$where
Your $where
variable appears to be incomplete in that it contains AND DEV_ID =
but without what you want to compare it with.
You need to fix the code that generates that where
sub-clause so that the resulting query is valid.
Your question is no clear enough for me, but in your sql code
$SQL = "SELECT * FROM ".TBL_DEVICE." WHERE DEV_STATUS='1' $where ORDER BY DEV_TYPE ASC";
why you are using $where
variable?? and what is it's expected value?
The basic Structure for select all data from a table is :
$SQL = "SELECT * FROM table_name WHERE id = desire_id";
Hope this help
I am assuming that your variable "$where" has this value => "AND DEV_ID =".
$where = "AND DEV_ID =";
first: complete your variable "$where".
$where = "AND DEV_ID = ".your_supposed_to_be_a_value_here.";
second: if you don't mind, change your variable name into something more relative.
third: assumed query
$where = "AND DEV_ID = ".your_supposed_to_be_a_value_here.";
$SQL = "SELECT * FROM `".TBL_DEVICE."` WHERE DEV_STATUS='1' $where ORDER BY DEV_TYPE ASC";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.