2017-03-05 53 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