From 0be35385d5f78880f73a35ee65544b6ab7fe6922 Mon Sep 17 00:00:00 2001 From: "dorian.hodin" Date: Wed, 23 Nov 2022 23:27:15 +0100 Subject: [PATCH] Try to resolve connection problem --- .idea/codeStyles/Project.xml | 1 - .idea/libraries/Dart_Packages.xml | 340 ++++++++++++------------- .idea/libraries/Dart_SDK.xml | 38 +-- Sources/php_script/script/config.php | 5 +- Sources/php_script/script/distance.php | 28 +- Sources/php_script/script/insert.php | 2 +- 6 files changed, 207 insertions(+), 207 deletions(-) diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index 7643783..6db4707 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -98,7 +98,6 @@ http://schemas.android.com/apk/res/android - ANDROID_ATTRIBUTE_ORDER
diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index f8237c9..04e2ec7 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -5,686 +5,686 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.idea/libraries/Dart_SDK.xml b/.idea/libraries/Dart_SDK.xml index cb79f3d..3dbed52 100644 --- a/.idea/libraries/Dart_SDK.xml +++ b/.idea/libraries/Dart_SDK.xml @@ -1,25 +1,25 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/Sources/php_script/script/config.php b/Sources/php_script/script/config.php index d515461..eac23db 100644 --- a/Sources/php_script/script/config.php +++ b/Sources/php_script/script/config.php @@ -6,8 +6,9 @@ $db_name="positiondaflmusic"; try { //Try to connect to the database $connect = mysqli_connect($host, $username, $password, $db_name); //Connecting to database }catch (mysqli_sql_exception){ //If the connection failed - print(json_encode("Failed to connect to MySQL, connection timeout")); //Return a json string, so the dart script can interpret the error - exit(-1); //Send a return code as -1, so insert.php can know if the connection is successful + echo "

HEY

"; + print(json_encode("Failed to connect to MySQL, connection timeout")); //Return a json string, so the dart script can interpret the error + exit(-1); //Send a return code as -1, so insert.php can know if the connection is successful } diff --git a/Sources/php_script/script/distance.php b/Sources/php_script/script/distance.php index 8ad361d..9cfa86d 100644 --- a/Sources/php_script/script/distance.php +++ b/Sources/php_script/script/distance.php @@ -2,21 +2,21 @@ function meters($lat1, $lng1, $lat2, $lng2): float { - $earth_radius = 6378137; // Radius of the Earth in meters : - $rlo1 = deg2rad($lng1); //Transform the coordinate longitude1 from degree to radian - $rla1 = deg2rad($lat1); //Transform the coordinate latitude1 from degree to radian - $rlo2 = deg2rad($lng2); //Transform the coordinate longitude2 from degree to radian - $rla2 = deg2rad($lat2); //Transform the coordinate latitude2 from degree to radian - $dlo = ($rlo2 - $rlo1) / 2; //Stock in $dlo the result of the calcul : ($rlo2 - $rlo1) / 2 - $dla = ($rla2 - $rla1) / 2; //Stock in $dla the result of the calcul : ($rla2 - $rla1) / 2 - $a = (sin($dla) * sin($dla)) + cos($rla1) * cos($rla2) * (sin($dlo) * sin($dlo)); //Do some operations to return the distance in meters + $earth_radius = 6378137; // Radius of the Earth in meters : + $rlo1 = deg2rad($lng1); //Transform the coordinate longitude1 from degree to radian + $rla1 = deg2rad($lat1); //Transform the coordinate latitude1 from degree to radian + $rlo2 = deg2rad($lng2); //Transform the coordinate longitude2 from degree to radian + $rla2 = deg2rad($lat2); //Transform the coordinate latitude2 from degree to radian + $dlo = ($rlo2 - $rlo1) / 2; //Stock in $dlo the result of the calcul : ($rlo2 - $rlo1) / 2 + $dla = ($rla2 - $rla1) / 2; //Stock in $dla the result of the calcul : ($rla2 - $rla1) / 2 + $a = (sin($dla) * sin($dla)) + cos($rla1) * cos($rla2) * (sin($dlo) * sin($dlo)); //Do some operations to return the distance in meters $d = 2 * atan2(sqrt($a), sqrt(1 - $a)); //Do some operations to return the distance in meters return round($earth_radius * $d); // Return the distance in meters between 2 GPS points } -$connect=""; //Else PHP send an error, "connect don't exist", but that work anyway, this is just to remove a fake error -$res=include "config.php"; //$res get the result of the calling of "config.php" -if ($res != 1){ //Check if config.php work - print (json_encode("Failed to connect to MySQL, connection timeout")); //Return a json string, so the dart script can interpret the error +$connect=""; //Else PHP send an error, "connect don't exist", but that work anyway, this is just to remove a fake error +$res=include "config.php"; //$res get the result of the calling of "config.php" +if ($res != 1){ //Check if config.php work + print (json_encode("Failed to connect to MySQL, connection timeout")); //Return a json string, so the dart script can interpret the error } if (!empty($_POST)) { $id = $_POST['id']; //Get the result of the POST method in id @@ -32,7 +32,7 @@ if (!empty($_POST)) { } } if ($lat1 == 0 && $lng1 == 0) { //Check if the user get found in the database - print(json_encode("ERROR No user found in the database")); //Return a json string, so the dart script can interpret the error + print(json_encode("ERROR No user found in the database")); //Return a json string, so the dart script can interpret the error exit(1); //Exit the actual script } $results = mysqli_query($connect, $query); //Execute again the SQL command to restart the fetch_row() @@ -50,7 +50,7 @@ if (!empty($_POST)) { } print(json_encode($listUser)); //Return a json string of the list listUser }else{ //If the method POST return nothing - print (json_encode("The POST didn't return any values")); //Return a json string, so the dart script can interpret the error + print (json_encode("The POST didn't return any values")); //Return a json string, so the dart script can interpret the error } diff --git a/Sources/php_script/script/insert.php b/Sources/php_script/script/insert.php index 7cb9fa6..84ffd22 100644 --- a/Sources/php_script/script/insert.php +++ b/Sources/php_script/script/insert.php @@ -22,5 +22,5 @@ if (!empty($_POST)) { VALUES('$id','$latitude','$longitude','$idMusic',CURRENT_TIMESTAMP);"; //Insert into the database the new data and new information about this user $results = mysqli_query($connect, $query); //Execute the SQL command }else{ //If the method POST return nothing - print (json_encode("The POST didn't return any values")); //Return a json string, so the dart script can interpret the error + print (json_encode("The POST didn't return any values")); //Return a json string, so the dart script can interpret the error } \ No newline at end of file