如果变量不为空,如何更新sql中的项?

I'm getting variable from parser.

If variable $desc is empty - my request just stops, but I need just pass it.

It's my part of code.

$desc = $description->plaintext;
if(!empty($desc)) {
    $query = "UPDATE snowcore_parser_products SET description = 'blabla' WHERE remote_id = '" . $dataId . "';";
} else {
    $query = "UPDATE snowcore_parser_products SET description = 'EMPTY' WHERE remote_id = '" . $dataId . "';";
}
$sql = mysqli_query($db, $query);

But if(!empty($desc)) doesn't work

Try this

$desc = $description->plaintext;
if(count($desc)>0) {
     $query = "UPDATE snowcore_parser_products SET description = 'blabla' WHERE  remote_id = '" . $dataId . "';";
} else {
    $query = "UPDATE snowcore_parser_products SET description = 'EMPTY' WHERE remote_id = '" . $dataId . "';";
}
$sql = mysqli_query($db, $query);

Are you sure $desc is empty, mind you a space or newline character will not make it empty. Check the value by debugging or by var_dump(). If there is space or newline you can use trim().

$desc = trim($description->plaintext);
if(!empty($desc)) {
$query = "UPDATE snowcore_parser_products SET description = 'blabla' WHERE remote_id = '" . $dataId . "';";
} else {
$query = "UPDATE snowcore_parser_products SET description = 'EMPTY' WHERE remote_id = '" . $dataId . "';";
}
$sql = mysqli_query($db, $query);