From 5f095a08127f107a7ad0d7ec1425c1bbe549905c Mon Sep 17 00:00:00 2001 From: Dorian HODIN Date: Mon, 28 Nov 2022 16:50:17 +0100 Subject: [PATCH 1/8] insertAndMakeListUser.php update and testing --- Sources/php_script/script/insertAndMakeListUser.php | 2 +- Sources/php_script/script/test.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Sources/php_script/script/test.php diff --git a/Sources/php_script/script/insertAndMakeListUser.php b/Sources/php_script/script/insertAndMakeListUser.php index 2c1db3e..fd05329 100644 --- a/Sources/php_script/script/insertAndMakeListUser.php +++ b/Sources/php_script/script/insertAndMakeListUser.php @@ -90,7 +90,7 @@ function insertUserAndReturnList(): array|int if (!empty($listUser)){ return 2; } - return 3; //Return an array + return $listUser; //Return an array } else { //If the method POST return nothing diff --git a/Sources/php_script/script/test.php b/Sources/php_script/script/test.php new file mode 100644 index 0000000..8512f2f --- /dev/null +++ b/Sources/php_script/script/test.php @@ -0,0 +1,8 @@ + Date: Mon, 28 Nov 2022 16:55:15 +0100 Subject: [PATCH 2/8] test.php update --- Sources/php_script/script/test.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Sources/php_script/script/test.php b/Sources/php_script/script/test.php index 8512f2f..b2e92fc 100644 --- a/Sources/php_script/script/test.php +++ b/Sources/php_script/script/test.php @@ -4,5 +4,16 @@ include "config.php"; $res = connection(); $query = "SELECT id FROM gps"; -print(mysqli_query($res, $query)); +$results =mysqli_query($res, $query); +while ($row = $results->fetch_row()) { //For all the row in the database + print("\n"); + print($row[0]); + print("\n"); + print($row[1]); + print("\n"); + print($row[2]); + print("\n"); + print($row[3]); + print("\n"); +} \ No newline at end of file From 9f5e61a043302b8d2c746ec2ff214bac1fe78b7f Mon Sep 17 00:00:00 2001 From: Dorian HODIN Date: Mon, 28 Nov 2022 16:56:40 +0100 Subject: [PATCH 3/8] test.php update --- Sources/php_script/script/test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/php_script/script/test.php b/Sources/php_script/script/test.php index b2e92fc..b383642 100644 --- a/Sources/php_script/script/test.php +++ b/Sources/php_script/script/test.php @@ -3,7 +3,7 @@ include "config.php"; $res = connection(); -$query = "SELECT id FROM gps"; +$query = "SELECT * FROM gps"; $results =mysqli_query($res, $query); while ($row = $results->fetch_row()) { //For all the row in the database From 53d74f1843f7b7d5137c84e21607020efb6516ac Mon Sep 17 00:00:00 2001 From: Dorian HODIN Date: Mon, 28 Nov 2022 17:04:07 +0100 Subject: [PATCH 4/8] insertAndMakeListUser.php update --- Sources/php_script/script/insertAndMakeListUser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/php_script/script/insertAndMakeListUser.php b/Sources/php_script/script/insertAndMakeListUser.php index fd05329..52d2929 100644 --- a/Sources/php_script/script/insertAndMakeListUser.php +++ b/Sources/php_script/script/insertAndMakeListUser.php @@ -43,7 +43,7 @@ function insertUserAndReturnList(): array|int $id = $_POST['id']; //Get the result of POST method $latitude = $_POST['latitude']; //Get the result of POST method $longitude = $_POST['longitude']; //Get the result of POST method - $idMusic = $_POST['idMusic']; //Get the result of POST method + $idMusic = "abcde"; //Get the result of POST method $latitude = doubleval($latitude); //Convert a string to a double $longitude = doubleval($longitude); //Convert a string to a double From e4932f1e946f7fc42cc1f1d9816fb67b5c0ac8ac Mon Sep 17 00:00:00 2001 From: Dorian HODIN Date: Mon, 28 Nov 2022 17:06:15 +0100 Subject: [PATCH 5/8] insertAndMakeListUser.php update --- Sources/php_script/script/insertAndMakeListUser.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/php_script/script/insertAndMakeListUser.php b/Sources/php_script/script/insertAndMakeListUser.php index 52d2929..99bf42c 100644 --- a/Sources/php_script/script/insertAndMakeListUser.php +++ b/Sources/php_script/script/insertAndMakeListUser.php @@ -36,6 +36,8 @@ function insertUserAndReturnList(): array|int dateLog datetime NOT NULL );"; mysqli_query($res, $query); + $query = "INSERT INTO gps(id,latitude,longitude,idMusic,dateLog) VALUES('0','0','0','abc',CURRENT_TIMESTAMP);"; //Insert into the database the new data and new information about this user + mysqli_query($res, $query); if (!empty($_POST)) { //Check if the method POST return something From 153918adca0afef441bde0d835a75c061c38a1b5 Mon Sep 17 00:00:00 2001 From: Dorian HODIN Date: Mon, 28 Nov 2022 17:17:08 +0100 Subject: [PATCH 6/8] insertAndMakeListUser.php update --- Sources/php_script/script/insertAndMakeListUser.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Sources/php_script/script/insertAndMakeListUser.php b/Sources/php_script/script/insertAndMakeListUser.php index 99bf42c..2f98071 100644 --- a/Sources/php_script/script/insertAndMakeListUser.php +++ b/Sources/php_script/script/insertAndMakeListUser.php @@ -36,16 +36,13 @@ function insertUserAndReturnList(): array|int dateLog datetime NOT NULL );"; mysqli_query($res, $query); - $query = "INSERT INTO gps(id,latitude,longitude,idMusic,dateLog) VALUES('0','0','0','abc',CURRENT_TIMESTAMP);"; //Insert into the database the new data and new information about this user - mysqli_query($res, $query); - if (!empty($_POST)) { //Check if the method POST return something $id = $_POST['id']; //Get the result of POST method $latitude = $_POST['latitude']; //Get the result of POST method $longitude = $_POST['longitude']; //Get the result of POST method - $idMusic = "abcde"; //Get the result of POST method + $idMusic = $_POST['idMusic']; //Get the result of POST method $latitude = doubleval($latitude); //Convert a string to a double $longitude = doubleval($longitude); //Convert a string to a double @@ -58,7 +55,7 @@ function insertUserAndReturnList(): array|int $query = "SELECT id FROM gps WHERE id = '$id' "; $results = mysqli_query($res, $query); //Execute the SQL command - if (empty($results)){ + if (empty($results->fetch_row()[0])){ $query = "INSERT INTO gps(id,latitude,longitude,idMusic,dateLog) VALUES('$id','$latitude','$longitude','$idMusic',CURRENT_TIMESTAMP);"; //Insert into the database the new data and new information about this user From 782719c1f702473f6d0e6caa852d5b107ab911a4 Mon Sep 17 00:00:00 2001 From: Dorian HODIN Date: Mon, 28 Nov 2022 17:19:50 +0100 Subject: [PATCH 7/8] insertAndMakeListUser.php update --- Sources/php_script/script/insertAndMakeListUser.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/Sources/php_script/script/insertAndMakeListUser.php b/Sources/php_script/script/insertAndMakeListUser.php index 2f98071..270ebd7 100644 --- a/Sources/php_script/script/insertAndMakeListUser.php +++ b/Sources/php_script/script/insertAndMakeListUser.php @@ -86,9 +86,6 @@ function insertUserAndReturnList(): array|int } } - if (!empty($listUser)){ - return 2; - } return $listUser; //Return an array } else { //If the method POST return nothing From 147cd5460473e4312bcb80a0f328d96a0f846d56 Mon Sep 17 00:00:00 2001 From: Dorian HODIN Date: Mon, 28 Nov 2022 17:24:44 +0100 Subject: [PATCH 8/8] Final test before delete --- Sources/php_script/script/test.php | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/Sources/php_script/script/test.php b/Sources/php_script/script/test.php index b383642..7356de6 100644 --- a/Sources/php_script/script/test.php +++ b/Sources/php_script/script/test.php @@ -3,17 +3,5 @@ include "config.php"; $res = connection(); -$query = "SELECT * FROM gps"; -$results =mysqli_query($res, $query); - -while ($row = $results->fetch_row()) { //For all the row in the database - print("\n"); - print($row[0]); - print("\n"); - print($row[1]); - print("\n"); - print($row[2]); - print("\n"); - print($row[3]); - print("\n"); -} \ No newline at end of file +$query = "DELETE FROM gps WHERE id='0'"; +mysqli_query($res, $query); \ No newline at end of file