I have goot the following function:
public function search_exists($word){
$word=trim($word);
$query="SELECT * FROM `search` WHERE `word`=$word";
echo $query;
$st=$this->pdo->query($query);
if($st->fetch()){
return true;
}
return false;
}
I want to check whether rows exist.. problem is that I am new to pdo..and It returns false.. when I know that there is a row..hmm
UPDATE:
About sql_injection:
I use this:
$word=$pdo->quote($_GET['search']);
I thought to withdraw data from the query like this:
public function search_exists($word){
$word=trim($word);
$query="SELECT search_id FROM `search` WHERE `word`=$word";
echo $query;
$st=$this->pdo->query($query);
while($row=$st->fetch()){
return $row['search_id'];
}
return false;
}
problem..that even the above query doesnt work
first of all : use prepared statement to bind a parameter :
now your query has no problem with quoting AND there is no possibility of sql injection.
Then, an other possibility is to use the count statement, it is strictly equivalent
}
About your update
If you want to get the data :