How to escape single quote from a token to use it in SQL query?
Disclaimer: you shouldn't be using the PHP filter module, ever, it's very bad practice and can open your site up to security holes. Adding a custom rules action is very easy and should always be the preferred implementation method for something like this.

As a technical exercise, though, something like this might work:

$text = &lt;&lt;&lt;EOF
[node:field-text-drupal]
EOF;

$title = &lt;&lt;&lt;EOF
[node:title]
EOF;

$args = [':text' =&gt; $text, ':title' =&gt; $title];
$sql = "UPDATE table SET text_database = NULLIF(:text, '') WHERE title = :title";
db_query($sql, $args);