diff options
| author | Savetheinternet <savetheinternet@n0v4.com> | 2010-12-18 01:18:03 +1100 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@n0v4.com> | 2010-12-18 01:18:03 +1100 |
| commit | 574256a01a3250d3fef4bb1f4c41b7da8c7bf9f9 (patch) | |
| tree | e28f61d1cbd177496dc4b43972606d85cc7b3ec7 /mod.php | |
| parent | 139514402da1c12f877548087a67ab0bac2458b5 (diff) | |
Use PDO for databases
Diffstat (limited to 'mod.php')
| -rw-r--r-- | mod.php | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -6,6 +6,7 @@ } require 'inc/config.php'; require 'inc/template.php'; + require 'inc/database.php'; require 'inc/user.php'; require 'inc/mod.php'; @@ -175,20 +176,21 @@ if(!preg_match('/^\w+$/', $b['uri'])) error(sprintf(ERROR_INVALIDFIELD, 'URI')); - mysql_query(sprintf( - "INSERT INTO `boards` VALUES (NULL, '%s', '%s', " . - (empty($b['subtitle']) ? 'NULL' : "'%s'" ) . - ")", - mysql_real_escape_string($b['uri']), - mysql_real_escape_string($b['title']), - mysql_real_escape_string($b['subtitle']) - ), $sql) or error(mysql_error($sql)); + $query = prepare("INSERT INTO `boards` VALUES (NULL, :uri, :title, :subtitle)"); + $query->bindValue(':uri', $b['uri']); + $query->bindValue(':title', $b['title']); + if(!empty($b['subtitle'])) { + $query->bindValue(':subtitle', $b['subtitle']); + } else { + $query->bindValue(':subtitle', null, PDO::PARAM_NULL); + } + $query->execute() or error(db_error($query)); // Open the board openBoard($b['uri']) or error("Couldn't open board after creation."); // Create the posts table - mysql_query(Element('posts.sql', Array('board' => $board['uri'])), $sql) or error(mysql_error($sql)); + query(Element('posts.sql', Array('board' => $board['uri']))) or error(db_error()); // Build the board buildIndex(); |
