自动脚本中的错误处理

I have a script that is run via CRON.

The script includes a selection of database calls which are saved into variables and used in calculations. The calculations are then saved into the database.

As the code runs automatically, I am unsure how to approach errors. For example, if one of the variables couldn't be found, this may throw off another part of the script and make it fail.

// Database call

// Assign variables
$variable1 = $row->record_1;
$variable2 = '???';
$variable3 = $row->record_3;

// Database call using variables
// WHERE col_1 = $variable2 

// ERROR

As this is an automated process, how best should you handle the errors?