dbdelta
demands that:
- You must put each field on its own line in your SQL statement.
- You must have two spaces between the words PRIMARY KEY and the definition of your primary key.
- You must use the key word KEY rather than its synonym INDEX and you must include at least one KEY.
- You must not use any apostrophes or backticks around field names.
- Field types must be all lowercase.
- SQL keywords, like CREATE TABLE and UPDATE, must be uppercase.
If we look at your call:
$sql_one="CREATE TABLE " . $table_add_toplist . '(
id INT(11) UNSIGNED AUTO_INCREMENT,
link_id INT(11),
visitor_ip VARCHAR(15)
click_at DATETIME NOT NULL,
site_votes INT(11),
on_page VARCHAR(255),
UNIQUE KEY id (id)
) '. $charset_collate .';';
We can see that you do not append a comma to the end of every line:
link_id INT(11),
visitor_ip VARCHAR(15)
click_at DATETIME NOT NULL,
So you have invalid SQL, as visitor_ip
lacks a comma at the end