Error: mysql_fetch_assoc inside Function

Asked

Viewed 72 times

2

function retornaStatusPesquisa($numeroStatus,$nomePessoa, $nomeTabela){
    $query = mysql_query("SELECT COUNT(status) AS valorStatus FROM $nomeTabela WHERE status=$numeroStatus AND nomePessoa='$nomePessoa'");
    $contador=mysql_fetch_assoc($query);
    return $contador;
}

I’m getting this mistake:

You have an error in your SQL syntax; check the manual that Corresponds to your Mysql server version for the right syntax to use near 'WHERE status=1 AND namePessoa='Joao'' at line 1

It’s probably because of $nomeTabela, I don’t know why this happens, could give a light?

1 answer

3

Browser other questions tagged

You are not signed in. Login or sign up in order to post.