lundi 10 août 2020

If Condition Always returning True php

I am working on a web app and i ran into this problem for example wether i have premium column in my database set to false/0 or true/1 it always returns that its false despite changing it to 1 , here s my if condition:

if(!$_SESSION['premium']){
  $dateDebut = date("Y/m/d", strtotime($_SESSION['creation']));
  $dateFin = date("Y/m/d", strtotime($dateDebut."+30 days"));
  $diff = abs(strtotime($dateFin) - strtotime(date("Y/m/d")));
  $years = floor($diff / (365*60*60*24));
  $months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
  $days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
  if($months==0){
    echo "<div>Status:<div id='right'>Encore gratuit pour $days jours</div></div>";
  } else {
    echo "<div>Status:<div id='right'>Encore gratuit pour $months mois</div></div>";
  }
} else {
  echo "<div>Status:<div id='right'>Premium</div></div>";
}

for example here i set verified to 1 so it should return the second part of the if condition which is premium but it returns the first part instead

Aucun commentaire:

Enregistrer un commentaire