Jump to content

nested if statements causing error


ploppy

Recommended Posts

hello. I seemed to have got lost with my if statements here and cannot see where to use elseif . I am getting the duplicate response message ok, but if I submit with blank input, it produces NaN error, which I know is JavaScript but I think it is because of the order of the if statements. If someone could help me with this I would be very grateful. Thanks.

 

if (!empty ($_POST['item']))
{
  $data = split(',',$_POST['item'][0]);
  $duplicates = array();

foreach ($data as $val)
{
if ( $val != "" )
{
  $sql = "SELECT custref FROM boxes WHERE custref='$val' Union SELECT item FROM act WHERE item='$val'";
  $qry = mysql_query($sql) or die(mysql_error());

  if(mysql_num_rows($qry))
  {
  $duplicates[] = $val;
  }
}
}

if(count($duplicates))
{
    $response_array['status'] = 'error';
    $response_array['message'] = 'No duplicate files';
}
}
//check the name field
elseif(empty($authorised)){

    //set the response
    $response_array['status'] = 'error';
    $response_array['message'] = 'Name cannot be blank';

//check the service field
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.