I'm trying to create a temporary table with football team data, but I get this error:
DB ERROR: You have an error in your SQL syntax; check the manual that correspond to your MySQL server version for the right syntax to use near) and t.situacaojogador = 'active'
Can anyone help me understand what's wrong? Follow my code.
$sql = "select codtime from jogador where codjogador=" . $_SESSION['codjogador'] . ";";
$rst = my_query($connR, $sql);
if(count($rst) > 0) {
$codtimejogadorlogado = $rst[0]['codtime'];
} else {
$codtimejogadorlogado = -1;
}
if($codtimejogadorlogado == '') {
$codtimejogadorlogado = '-1';
}
$sql = "create temporary table tmptime as
(select t.codtime, t.nome, j.codjogador
from time t
left join jogador j on j.codtime=t.codtime
where j.codtime in ($codtimejogadorlogado) and t.situacaojogador = 'ativo');";
my_execute($connR, $sql);
Solved, I put another if to check if the codtime was empty. Updated code.