I have a function,
that returns to me always a mistake, even if in the phpmyadmin when I past the query there is a result.
I guess there is something wrong in my query but I don't know what. I used to do my code doing mysql_real_escape_string, then I turn to PDO, they told me I should do a prepare for escaping GET vars, so I tried do do it.
Below is my query
public static function getDetailService($param) {
global $bdd;
$detail = $bdd->prepare('SELECT
spb_services.spb_services__name,
spb_services.spb_services__description,
spb_services.spb_services__banner,
spb_services.spb_services__tabs,
spb_services.spb_services__category
FROM spb_services
WHERE spb_services.spb_services__name LIKE :service');
$detail->bindValue(':service', $_GET[$param], PDO::PARAM_STR);
$resultat = $detail->fetchAll(PDO::FETCH_ASSOC);
//var_dump($_GET[$param]);
$detail->debugDumpParams();
$lignes = $detail->fetchColumn();
//var_dump($lignes);
$detail = $detail->fetchAll(PDO::FETCH_ASSOC);
$retour = ($lignes > 0) ? array('status' => 'ok') : array('status' => 'error');
var_dump($retour);
}
When I call the function : $service = nosServices::getDetailService('service');
Var dump of var_dump($_GET[$param])
return to me what expected (from the url)
Then I did $detail->debugDumpParams();
I past the query in my localhost phpmyadmin, it returns to me what expected but not when using PDO.
I guess a small things is wrong bu tI have no idea what.
This returns no mistakes, but always error, as if there is no num_rows_result
To sum up the trouble, the GEt returns what expected, but when we go to the query, it return no result (except in my phpmyadmin copy and paste the query)
Anykind of help will be much appreciated
Edit : modifications done as expected by other users