change to SQL

This commit is contained in:
schrom01 2023-02-15 13:50:12 +01:00
parent 0e5864370f
commit 973e5da155
1 changed files with 3 additions and 1 deletions

View File

@ -23,13 +23,15 @@ if (!$link) {
die('Could not connect to Database: ' . mysql_error()); die('Could not connect to Database: ' . mysql_error());
} }
//if connection is successfully you will see message below //if connection is successfully you will see message below
echo 'Connected successfully to Database'; echo 'Connected successfully to Database<br>';
mysqli_close($link); mysqli_close($link);
//$mysqli = new mysqli($databaseAddress, $databaseUser, $databasePassword, $databaseName); //$mysqli = new mysqli($databaseAddress, $databaseUser, $databasePassword, $databaseName);
function saveToDatabase($contentArray, $mysqli) { function saveToDatabase($contentArray, $mysqli) {
echo "sending Query to Database<br>";
$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]"); $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 "Query sent<br>";
echo $response; echo $response;
return $response; return $response;
} }