diff --git a/dataCollector/dataCollector.php b/dataCollector/dataCollector.php
index 9b1d9e0..7ad6d17 100644
--- a/dataCollector/dataCollector.php
+++ b/dataCollector/dataCollector.php
@@ -18,13 +18,18 @@ $databasePort = "3306";
$databaseName = "u517357132_genderwatchpro";
$databaseUser = "u517357132_genderwatchpro";
$databasePassword = "zU!7gRHA6x";
-$mysqli = new mysqli($databaseAddress, $databaseUser, $databasePassword, $databaseName);
+$link = mysqli_connect($databaseAddress, $databaseUser, $databasePassword, $databaseName);
+if (!$link) {
+ die('Could not connect to Database: ' . mysql_error());
+}
+//if connection is successfully you will see message below
+echo 'Connected successfully to Database';
-
-$mysqli = new mysqli($databaseAddress, $databaseUser, $databasePassword, $databaseName);
+mysqli_close($link);
+//$mysqli = new mysqli($databaseAddress, $databaseUser, $databasePassword, $databaseName);
function saveToDatabase($contentArray, $mysqli) {
- $response = $mysqli->query("INSERT INTO `topics` (`id`, `fullJSON`, `timeWatchM`,`timeWatchW`, `timeWatchD`, `countWatchM`, `countWatchW`, `countWatchD`) values ($contentArray[0], $contentArray[2], $contentArray[3], $contentArray[4], $contentArray[5], $contentArray[6], $contentArray[7], $contentArray[8]) ON DUPLICATE KEY UPDATE `id` = $contentArray[0]");
+ $response = mysqli_query($mysqli, "INSERT INTO `topics` (`id`, `fullJSON`, `timeWatchM`,`timeWatchW`, `timeWatchD`, `countWatchM`, `countWatchW`, `countWatchD`) values ($contentArray[0], $contentArray[2], $contentArray[3], $contentArray[4], $contentArray[5], $contentArray[6], $contentArray[7], $contentArray[8]) ON DUPLICATE KEY UPDATE `id` = $contentArray[0]");
echo $response;
return $response;
}
@@ -41,7 +46,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
echo "POST Request received.
";
if(property_exists($entityBodyObject, "id")) {
- saveToDatabase(objectToArray($entityBodyObject, $entityBody), $mysqli);
+ saveToDatabase(objectToArray($entityBodyObject, $entityBody), $link);
echo "
Data saved.
";
}
} elseif($_SERVER['REQUEST_METHOD'] === 'GET') {
@@ -53,5 +58,5 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
-
+mysqli_close( );