joeros Posted June 11, 2010 Share Posted June 11, 2010 Hi, I am Very new to php but i have experience in other coding. I am trying to place a variable into some code that queries a database. This code works $x->setQuery("*", "people","gender","gender='m'"); This code also works $qry = "gender='f'"; $x->setQuery("*", "people","gender",$qry); And this code does not work nor does it throw any error it just does not return any records $ qry = chr(34); $ qry .= "gender="; $ qry .= chr(39); $ qry .= $PCode; $ qry .= chr(39); $ qry .= chr(34); Can anyone explain how to achieve what I am trying to do and/or explain why the above does not work? This is the actual query being referenced /** * Set the SELECT query * * @param string $fields Feilds to fetch from table. * for all columns * @param string $table Table to select from * @param string $primay Optional primary key column * @param string $where Optional where condition */ public function setQuery($fields, $table, $primary = '', $where = '') { $this->primary = $primary; $this->select_fields = $fields; $this->select_table = $table; $this->select_where = $where; } Quote Link to comment Share on other sites More sharing options...
joeros Posted June 11, 2010 Author Share Posted June 11, 2010 Bugger me, as soon as i post i sit back and look at the code and the answer comes to me. it's just a matter of dropping the quotes off the begining and the end of the string and then it returns the correct result. oh well it is good to find the solution yourself Quote Link to comment Share on other sites More sharing options...
Alex Posted June 11, 2010 Share Posted June 11, 2010 For future reference, if your question is answered it's appreciated if you mark it as solved so people don't waste their time looking at it. There's a button at the bottom of the page to do so. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.