title: How to compare two values?
body: <p>From my code I am able to enter a value for first time (when database is empty), second time it is not working even for the different users with a different plant name. If user 1 enters a plant name like Apple for first time it is saved, but not any following times.
  Is this a correct way of writing MySQL code, when I want to compare two values?</p>
  
  <pre><code>$plant = $_SESSION['plant'];
  $user = $_SESSION['user'];
  $q = mysqli_query($con, "select plantname='$plant' from tree where
  user = '$user'");
  if (mysqli_num_rows($q) &gt; 0) {
    Header('Location: home.php');
    exit;
  } else {
    $query = "insert into tree(plantname,user)
    values('$plant', '$user')";
    $q = mysqli_query($con, $query)or die("Could Not Perform the Query");
    Header('Location: home.php');
    exit;
  }
  </code></pre>