mysql - PHP syntax error or access violation: 1064 - using variable in where clause -
pulling hair out on one, i've tried number of things in terms of changing escape characters variable , nothing working including changing '". $r."' etc.
if hard code variable constant works. e.g $r = "word";
i've renamed variables random letters in case reserved words.
i've gone far setting logging mysql , have compared statements , they're identical, difference being 1 submitted via text box , other has been set constant.
model:
public static function searchprofile() { $r = request::post('w'); $args = ""; if ($r) {$args = "`info_tradingstatus` = '$r'";} $database = databasefactory::getfactory()->getconnection(); $sql = "select profile_id, profile_name profile_seeker $args";
view:
<input type="text" name="w" class="form-control" placeholder="enter keyword" aria-describedby="basic-addon1">
controller:
public function search_action() { profilemodel::searchprofile( request::post('w'), redirect::to('profile/searchresults')); }
hi think problem when $r empty, please try:
public static function searchprofile() { $r = request::post('w'); $args = " 1 "; if ($r) {$args = "`info_tradingstatus` = '".$r."'";} // in case $database = databasefactory::getfactory()->getconnection(); $sql = "select profile_id, profile_name profile_seeker $args";
Comments
Post a Comment