Did that already, the code now looks like this:
if ($_GET['action'] == "on") {
//to turn relay number 1 on, we issue the command
$serial->sendMessage("on");
} else if ($_GET['action'] == "deviceoff") {
$serial->deviceClose();
Still no luck