aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiam McLoughlin <hexxeh@hexxeh.net>2011-07-27 20:29:49 +0100
committerLiam McLoughlin <hexxeh@hexxeh.net>2011-07-27 20:29:49 +0100
commit5099c71493abe193f23b7f0a7381e539bc67bb33 (patch)
tree7628542c989bace2895427d34959b5f3fcbd2150 /client.php
parentAdded disk size cap (diff)
downloadgentoaster-5099c71493abe193f23b7f0a7381e539bc67bb33.tar.gz
gentoaster-5099c71493abe193f23b7f0a7381e539bc67bb33.tar.bz2
gentoaster-5099c71493abe193f23b7f0a7381e539bc67bb33.zip
Moved to using mysqli and prepared statements
Diffstat (limited to 'client.php')
-rw-r--r--client.php19
1 files changed, 11 insertions, 8 deletions
diff --git a/client.php b/client.php
index e2284b4..56313ae 100644
--- a/client.php
+++ b/client.php
@@ -21,13 +21,16 @@
echo "Job sent, handle was ".$handle." - hash ".$handlehash."\n";
- $db = mysql_connect(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD);
- if (!$db) {
- die("Could not connect to database ".mysql_error());
+ $db = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME,
+ MYSQL_PASSWORD, MYSQL_DATABASE);
+ if (mysqli_connect_errno()) {
+ die("Could not connect to database ".mysqli_connect_error());
}
- mysql_select_db(MYSQL_DATABASE);
- $query = "INSERT INTO builds (id, handle)".
- ." VALUES('".$handlehash."','".$handle."')";
- mysql_query($query);
- echo "Job handle mapping added to database\n";
+ $query = "INSERT INTO builds (id, handle) VALUES(?, ?)";
+ $stmt = $db->prepare($query);
+ $stmt->bind_param("ss", $handlehash, $handle);
+ $stmt->execute();
+ $stmt->close();
+ $db->close();
+ echo "Job handle mapping added to database\n"; \ No newline at end of file