I am writing an android program which use http post to connect to a php script to connect to mysql database. query is the variable to be sent over.
Here is part of my code:
String query = "select `retailer`.`name` as `retailer`, `product`.`name` as `product`, `product`.price, `promotion`.discount, `promotion`.discount_type";
query = query.concat(" from `retailer`, `consumer`, `product`, `promotion`, `sell`, `proximity`");
query = query.concat(" where `consumer`.`email` = '"+consumer_email+"'");
query = query.concat(" and `proximity`.`retailer_id` = `retailer`.`id`" +
" and `proximity`.`consumer_id` = `consumer`.`id`" +
" and `sell`.`retailer_id` = `retailer`.`id`" +
" and `sell`.`product_id` = `product`.`id`" +
" and `product`.`promotion_id` = `promotion`.`id`");
Note that consumer_email is a string containing the email i want to query. However i keep getting syntax error with this. if i take away the line consumer.email = '"+consumer_email+"'", it is able to process with no error.
What i want to ask if there's any way to solve this problem? Is it the single quote surrounding the email that is causing the problem?