Current I'm trying to query a COUNT(*) using user input, so I want to prepare it, but when I do it there are no response, also I made using this:
Row count with PDO as example, (prepare and query) but they both seems to doesn't work. Why? theres no reason...
$count = $con->query("SELECT COUNT(*) FROM $table WHERE senha='$senha' AND var='{$ar[$i]}'")->fetchColumn();
if($count!=0){
$q = $con->prepare("UPDATE $table SET value=':value' WHERE senha=':senha' AND var=':var'");
$q->execute(array(':senha' => $senha, ':value' => $ar[$i+1], ':var' => $ar[$i]));
}else{
$q = $con->prepare("INSERT INTO $table (id,senha,var,value) VALUES (NULL, ':senha', ':var', ':value')");
$q->execute(array(':senha' => $senha, ':var' => $ar[$i], ':value' => $ar[$i+1]));
}
When I were using his first example (using prepare not query passing values using array) didn't work at all, the query one return a number but does not work the if
(update
or insert
) part I've tried a bunch of things and outputs, nothing worked...