user6508741 user6508741 - 5 months ago 12
PHP Question

I am getting php fetal error

Whats wrong I am doing with this code. I am getting fetal error. Please help to solve this out. I think everything is fine but its not working at all

if (!empty($_POST['pic_tobe_add'])){

$pic_tobe_add = $_POST['pic_tobe_add'];

if (count($pic_tobe_add)<=6); {

$pic1 = $pic_tobe_add[0];
empty($pic_tobe_add[1]) ? $pic2 = "NA" : $pic2 = $pic_tobe_add[1];
empty($pic_tobe_add[2]) ? $pic3 = "NA" : $pic3 = $pic_tobe_add[2];
empty($pic_tobe_add[3]) ? $pic4 = "NA" : $pic4 = $pic_tobe_add[3];
empty($pic_tobe_add[4]) ? $pic5 = "NA" : $pic5 = $pic_tobe_add[4];
empty($pic_tobe_add[5]) ? $pic6 = "NA" : $pic6 = $pic_tobe_add[5];

Answer

You typed wrong code. if (count($pic_tobe_add)<=6); this is wrong. please remove ; from your if statement or replace with these codes below:

if (!empty($_POST['pic_tobe_add'])){

  $pic_tobe_add = $_POST['pic_tobe_add'];

  if (count($pic_tobe_add)<=6) {

  $pic1 = $pic_tobe_add[0]; 
  empty($pic_tobe_add[1]) ? $pic2 = "NA" : $pic2 = $pic_tobe_add[1];
  empty($pic_tobe_add[2]) ? $pic3 = "NA" : $pic3 = $pic_tobe_add[2];
  empty($pic_tobe_add[3]) ? $pic4 = "NA" : $pic4 = $pic_tobe_add[3];
  empty($pic_tobe_add[4]) ? $pic5 = "NA" : $pic5 = $pic_tobe_add[4];
  empty($pic_tobe_add[5]) ? $pic6 = "NA" : $pic6 = $pic_tobe_add[5];