// php, using wordpress to send a raw query string
$output = $wpdb->query("
INSERT INTO wp_priceGrids (gridId) VALUES (NULL); SELECT MAX(gridId) FROM wp_priceGrids;
");
Results in:
WordPress database error: [You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT MAX(gridId) FROM wp_priceGrids' at line 1]
INSERT INTO wp_priceGrids (gridId) VALUES (NULL); SELECT MAX(gridId) FROM wp_priceGrids;
Tried
- Deleting / commenting the 2nd line. Works. A new row is added and visible as I check through CLI
- Adding backticks (``) around the
field name
gridId
. Seems not to affect anything, error is the same - Removing the hard return between statements (as you can see above). No change
Question
Is it a syntax error? I've checked against examples and I think what I have matches their formats
owner@G700:~$ mysql --version
mysql Ver 14.14 Distrib 5.7.25, for Linux (x86_64) using EditLine wrapper
owner@G700:~$ php --version
PHP 7.2.15-0ubuntu0.18.04.1 (cli) (built: Feb 8 2019 14:54:22) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Xdebug v2.7.0, Copyright (c) 2002-2019, by Derick Rethans
with Zend OPcache v7.2.15-0ubuntu0.18.04.1, Copyright (c) 1999-2018, by Zend Technologies