12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
- require_once("../../php/db_utils.php");
-
- try {
- // Connect to the database
- $database = db_connect();
-
- // Incoming data
- $canvasId = $_POST["canvas_id"];
-
- // Check if the tag already exists
- $query = 'SELECT canvas_public FROM canvas WHERE canvas_id = "' . $canvasId . '";';
-
- $recordSet = db_query_return($database, $query);
-
- $record = mysqli_fetch_assoc($recordSet);
- $public = $record["canvas_public"];
- mysqli_free_result($recordSet);
-
- // If the canvas is public
- if($public == "0") {
- // Update description
- $query = 'UPDATE canvas SET canvas_public="1" WHERE canvas_id="' . $canvasId . '";';
- echo("1");
- }
- // Else if the canvas is not public
- else if($public == "1") {
- // Add new tag with the description
- $query = 'UPDATE canvas SET canvas_public="0" WHERE canvas_id="' . $canvasId . '";';
- echo("0");
- }
-
- // Update old project title
- db_query_no_return($database, $query);
-
- // Close the connection to the database
- db_close($database);
- }
- catch(Exception $e) {
- $errorMsg = $e->getMessage();
- print_r($errorMsg);
- }
- ?>
|