Changed cmd Query on Api index.php

To avoid  "Notice : undefined variables " changed the way the cmd query
is built by validating each argument Not empty into the cmd command
string