10.1.15-MariaDB, PHP 5.4
Code used:
$table = 'abc';
mysql_query("ALTER TABLE `$table` ADD PRIMARY KEY (`col`)");
Error:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near \'ALTER TABLE...
I have tried KEY `PRIMARY` and remove all backquotes to no avail.
Updates: It has nothing to do with extensions whatsoever, tested with mysqli_ same error. However, repeated test using same script in different server environment is fine.