如何修复未定义的偏移量

时间:2014-12-10 11:13:54

标签: php

我有一个php通知,说明未定义的偏移量:第18行的5(在本例中)。

1   <?php session_start();
2
3   require_once ('admin/config.inc.php');
4
5   $key = (empty($_GET['key'])) ? "" : $_GET['key'];
6   $v = (empty($_GET['v'])) ? "1" : $_GET['v'];
7
8   $result_Video = mysqli_query($db , "SELECT mv.video_link_1, mv.video_link_2,mv.sort FROM `mra_videos` AS mv INNER JOIN `mra_channels` AS mc ON mc.id = mv.channel_id WHERE (mc.code ='" . $key . "') AND (mv.sort = " . $v . ") LIMIT 1");
9
10  $rows_Video = mysqli_fetch_array($result_Video , MYSQLI_NUM);
11  $video_1 = get_youtube_id_from_url($rows_Video['video_link_1']);
12  $video_2 = get_youtube_id_from_url($rows_Video['video_link_2']);
13
14  function get_youtube_id_from_url($urls) {
15  if (stristr($urls, 'youtu.be/')) { preg_match('/(https|http):\/\/(.*?)\/([a-zA-Z0-9_]{11})/i', $urls, $final_ID);
16  return $final_ID[3];
17  } else { preg_match('/(https|http):\/\/(.*?)\/(embed\/|watch\?v=|(.*?)&v=|v\/|e\/|.+\/|watch.*v=|)([a-zA-Z0-9_]{11})/i', $urls, $IDD);
18  return $IDD[5];
19  }
20  }
21  ?>

造成这种情况的原因是什么?如何防止这种情况发生?

0 个答案:

没有答案