I am making a PHP script at the moment and I am making an install page to go with it. Before running the install script the user has to edit the config file and enter their database credentials (they have to create the database first).
The install script starts by checking they have met the requirements. If they have then display the "Import Tables" button. This is where I am having problems. Here is my code:
<?php
if (isset($_POST['step2'])) {
if (isset($success_php, $success_mysqli, $step_1_complete)) {
// Import SQL tables
$sql = ("
CREATE TABLE `banned_ips` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` varchar(15) NOT NULL,
`reason` text NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `ip` (`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=13 ;
");
if ($db->execute($sql)) {
$success_import = true;
$step_2_complete = true;
}
$db->close();
}
}
}
?>
I was thinking of loading it straight from the .sql
file however I am trying to make the script as compatible as I can across different servers, so therefore, I chose to do the query like so.
What I am asking is whether there is an issue with my above query and if so, how can I resolve it. At the moment when I click the button to test it, the table and its columns are not created.