I have an existing MySQL (version 5.6.12) table called 'users' and am trying to set the column defaults via php (version 5.4.12), for example:
$query = "ALTER TABLE users ALTER username SET DEFAULT NULL";
$result = mysqli_query($query);
However this generates a SQL error (which results in the message 'query is empty'). 'username' is a VARCHAR(200) type column.
Using a quoted literal (such as 'John') for the default value results in the same error. (Just for kicks, though I am using MySQL I have also tried modifying the query according to SQL/MS Access or Oracle syntax but it still doesn't work).
What am I doing wrong?
EDIT: Problem solved. The above query is fine and nothing is wrong.
I made an incredibly dumb error and forgot $
sign in front of $query
, i.e. my code was written $result = mysqli_query(query);
(Just so you know, I am a programmer with decades of experience.)