I am having a problem with my SQL query: I am using several MySQL queries, for example:
$sql = "SELECT * FROM lz".$ac." WHERE class='".$class."'";
$db_erg = mysqli_query( $conn, $sql );
if ( ! $db_erg )
{
die('Error: ' . mysqli_error());
}
And this works without any problem. But now below the code example, I want to check if the value in another table exits. But the query gives me an error:
$sqlproject ="SELECT * FROM `lz".$ac."project` WHERE `id`='".$zeile[id]."' AND `quartal`='".$quart."'";
echo $sqlprojekt; // To see if the sql statement is ok --> it is
$pro_erg = mysqli_query( $conn, $sqlprojekt );
if (!$pro_erg ){echo 'Error:';}
if($pro_erg->num_rows >0) { echo "Table exists";}
I can not find my mistake... The top code example works, why does my code with $prog_erg does not work???
The SQL statement seems to be ok, if I use it directly in PHPMyAdmin it shows me the values I need.
Maybe someone sees my mistake?