Mysql multiline statement causes syntax error
Your multiquery is subject to a race condition. You may not get back the value of the insert you do.

Use insert-id like:

$output = $wpdb-&gt;query("
      INSERT INTO wp_priceGrids (gridId) VALUES (NULL)";
$lastid = $wpdb-&gt;insert_id;


I've also heard the multiquery aspect of the mysql protocol is generally considered a mistake. Recommend avoiding it.