title: Check if the whole row exists
body: <p>I would like to know what is wrong with my code.. What I'm trying to do is POST data INTO my database <strong>BUT BEFORE INSERT</strong>, check if an EQUAL row exists and if exists show an message.. I tried it:</p>
  
  <p><strong>Here's my querys at the top of the page:</strong></p>
  
  <pre><code>if(isset($_POST['submitAddEvents'])){
  
      // Verify if the data exists
      if(!filter_var($_POST['teamA'] &amp;&amp; $_POST['teamB'] &amp;&amp; $_POST['eventDate'])){
          $stmt = $db-&gt;prepare('SELECT * FROM events WHERE teamA = :teamA AND teamB = :teamB AND eventDate = :eventDate');
          $stmt-&gt;execute(array(
              ':teamA' =&gt; $_POST['teamA'],
              ':teamB' =&gt; $_POST['teamB'],
              ':eventDate' =&gt; $_POST['eventDate'],
          ));
          $row = $stmt-&gt;fetch(PDO::FETCH_ASSOC);
      }
  
      $statement = $db-&gt;prepare("INSERT INTO events(teamA, teamB, eventDate, `time`, live) VALUES (:teamA, :teamB, :eventDate, :timeOfEvent, :live)");
      $statement-&gt;execute(array(
          ':teamA' =&gt; $_POST['teamA'],
          ':teamB' =&gt; $_POST['teamB'],
          ':eventDate' =&gt; $_POST['date'],
          ':timeOfEvent' =&gt; $_POST['timeOfEvent'],
          ':live' =&gt; $_POST['live'],
      ));
      $id = $db-&gt;lastInsertId('ID');
  }
  ?&gt;
  </code></pre>
  
  <p><strong>Here's my script at the bottom of the page:</strong></p>
  
  <pre><code>&lt;script&gt;
      //Saving Data
      $('#saveButton').click(function(){
          var teamA = $('#teamA').val();
          var teamB = $('#teamB').val();
          var date = $('#date').val();
          var timeOfEvent = $('#timeOfEvent').val();
          var live = "0";
          if($("#live").is(':checked'))
              live = $('#live').val();
  
          $.ajax({
              url  : "&lt;?= $_SERVER['PHP_SELF'] ?&gt;",
              type : "POST",
              async: false,
              data :
              {
                  'submitAddEvents' : 1,
                  'teamA' : teamA,
                  'teamB' : teamB,
                  'date' : date,
                  'timeOfEvent' : timeOfEvent,
                  'live' : live,
              },
              success:function(re)
              {
                      window.location = "addEvents.php";
              }
          });
      });
      &lt;/script&gt;
  </code></pre>
  
  <p>But didn't work, the data saves into database and doesn't pass for any verification on ajax submit... Could someone tell me what's wrong with that? Can someone help me to fix it?</p>