title: Notification appears to be successful even if no data has been added to database
body: <p>So I have these codes wherein I want a notification to appear in every event. I want to check if the record exists, then a notification will appear, saying the college already exists. But that doesn't happen tho. I keep on inputting duplicate input, but the notification still says it's successful. Is there a mistake in my code?</p>
  
  <blockquote>
    <p><strong>add-college.php</strong></p>
  </blockquote>
  
  <pre><code>&lt;?php
  function findDuplicate($code) {
      try {
          include($_SERVER['DOCUMENT_ROOT']."/config/db-config.php");
  
          $sql = "SELECT * FROM colleges WHERE collegecode = ?";
          $stmt = $conn-&gt;prepare($sql);
          $stmt-&gt;bind_param("s", $code);
          $stmt-&gt;execute();
          $stmt-&gt;store_result();
  
          if ($stmt-&gt;num_rows &gt; 0) {
              return true;
          }
          else {
              return false;
          }
      }
      catch (Exception $e) {
          return false;
      }
  }
  
  try {
      include($_SERVER['DOCUMENT_ROOT']."/config/db-config.php");
  
      $code = $_POST['code'];
      $name = $_POST['name'];
      $result = array();
  
      if (findDuplicate($code)) {
          $result['message'] = 'duplicate';
      }
      else {
          $sql = "INSERT INTO colleges(collegecode, collegename) VALUES(?, ?)";
          $stmt = $conn-&gt;prepare($sql);
          $stmt-&gt;bind_param("ss", $code, $name);
          if ($stmt-&gt;execute()) {
              $result['message'] = 'success';
          }
          else {
              $result['message'] = 'error';
          }
      }
  
      echo json_encode($result);
  }
  catch (Exception $e) {
      echo json_encode($result);
  }
  ?&gt;
  </code></pre>
  
  <blockquote>
    <p><strong>script.js</strong></p>
  </blockquote>
  
  <pre><code>$("#save-new").click(function() {
          var form = $("#add-college");
          var code = $("#code").val();
          var name = $("#name").val();
  
          $.ajax({
              type: "POST",
              data: {
                  code: code,
                  name: name
              },
              url: "../ajax/add-college.php",
              dataType: "html",
              success: function(data) {
                  if (data.message = "success") {
                      $.notify({
                          // options
                          message: 'College has been added.'
                      },{
                          // settings
                          type: 'success'
                      });
                  }
                  else if (data.message = "duplicate") {
                      $.notify({
                          // options
                          message: 'College already exists.'
                      },{
                          // settings
                          type: 'warning'
                      });
                  }
                  else {
                      $.notify({
                          // options
                          message: 'College cannot be added.'
                      },{
                          // settings
                          type: 'error'
                      });
                  }
  
                  $("#code").val("");
                  $("#name").val("");
  
                  $("#add-new").modal('hide');
  
                  showColleges();
              }
          });
      });
  </code></pre>