check-version.php 866 B

123456789101112131415161718192021222324252627282930313233
  1. <?php
  2. require_once("../../php/db_utils.php");
  3. try {
  4. // Connect to the database
  5. $database = db_connect();
  6. // Incoming data
  7. $canvasId = $_POST["canvas_id"];
  8. // Declare query
  9. $query = 'SELECT canvas_version FROM canvas WHERE canvas_id = "' . $canvasId . '";';
  10. // Run query
  11. $recordSet = db_query_return($database, $query);
  12. // Return the version if it exists
  13. $record = mysqli_fetch_assoc($recordSet);
  14. $canvasVersion = $record["canvas_version"];
  15. mysqli_free_result($recordSet);
  16. echo($canvasVersion);
  17. // Close the connection to the database
  18. db_close($database);
  19. }
  20. catch(Exception $e) {
  21. $errorMsg = $e->getMessage();
  22. print_r($errorMsg);
  23. }
  24. ?>