2017-03-05 52 views
0

数据从数据库中检索与传输软件断电流循环迭代,不断循环在PHP

while($row_posts = mysql_fetch_array($run_posts)) 
    { 
    $post_id1=$row_posts['userID']; 
    $post_title=$row_posts['torrent_hash']; 

检查散列值

try{ 
    $transmission = new Transmission\Transmission(); 
    $torrent = $transmission->get($post_title); 
    $torrent->getName(); 
    } 
    catch (Exception $e) { 
      echo 'Caught exception: ', $e->getMessage(), "\n"; 
     } 

如果在传输,则显示没有找到散列ID像下面的错误

Caught exception: Torrent with ID 58bd21a7938cb1d65f737bcb6031111816d924d9 not found 
Notice: Undefined variable: torrent in C:\xampp\htdocs\final\info.php on line 46 

Fatal error: Call to a member function isFinished() on a non-object in C:\xampp\htdocs\final\info.php on line 46 

我需要输出像如果运行时异常发生然后简单地打破第一个循环,并从数据库执行第二个值是可能的?

回答

1

在catch块中尝试命令continue;

continue在循环结构中用于跳过当前循环迭代的其余部分,并继续执行条件评估和下一次迭代的开始。

请参阅Php manual