$consulta = "SELECT * FROM mi_tabla ORDER BY id DESC LIMIT 1"; $q = mysql_query($dbname,$consulta) or die($consulta."<br>".mysql_error());