get-owner.php 934 B

12345678910111213141516171819202122232425262728293031323334
  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.user_id
  10. FROM collaborators
  11. INNER JOIN canvas
  12. ON canvas.canvas_id = collaborators.canvas_id
  13. AND canvas.canvas_id = "' . $canvasId . '" LIMIT 1;';
  14. // Run query
  15. $recordSet = db_query_return($database, $query);
  16. $record = mysqli_fetch_assoc($recordSet);
  17. mysqli_free_result($recordSet);
  18. echo($record["user_id"]);
  19. // Close the connection to the database
  20. db_close($database);
  21. }
  22. catch(Exception $e) {
  23. $errorMsg = $e->getMessage();
  24. print_r($errorMsg);
  25. }
  26. ?>