4 Database connection test
7 $fields = array('host', 'user', 'pass', 'db');
10 foreach($fields as $field) {
11 $post[$field] = isset($_POST[$field]) ?
$_POST[$field] : false;
14 if(empty($post['db'])) {
15 $errors[] = 'Please specify a database name';
18 if(empty($post['host'])) {
19 $errors[] = 'Please specify a database host';
25 $dsn = 'mysql:dbname=' . $post['db'] . ';host=' . $post['host'];
26 new PDO($dsn, $post['user'], $post['pass']);
27 } catch(PDOException
$e) {
28 $errors[] = $e->getMessage();
33 header('Content-Type: text/plain');
36 //no errors we're all gooood
39 echo implode(', ', $errors);