Disculpame me equivoque..
Código PHP:
$conexion = mysql_connect('localhost','prueba','root','password');
mysql_select_db('prueba', $conexion);
if (!@mysql_select_db('prueba')) {
exit('<p>Unable to locate the joke ' .
'database at this time.</p>');
}
prueba hacer un echo aqui..
echo $tabla;
if (mysql_select_db('prueba'))
{
sql="select * from '$tabla' where campo='$variable'";
}
Esto te deberia servir..
Y mis disculpas..
Tambien prueba dandole un echo '$tabla' al valor de las variables antes de realizar el SQL..
Salu2..!