Jump to content
Sign in to follow this  
exodusyka

PHP isset

Recommended Posts

while($row = mysqli_fetch_array($result))
    {
      $ide = $row['id'];
      $name = $row['name'];
      $type = $row['type'];
      $logo = $row['logo'];
      $bgimage = $row['bgimage'];
      $about = $row['about'];
      $creator_id = $row['user_id'];
      $skill = $row['skill'];
      $win = $row['win'];
      $loses = $row['loses'];
      $warn = $row['warn'];

      

      if (isset($about)) {
        $abouterror = '<span class="badge badge-danger">Komandas apraksts nav pieejams!</span>';
      }
      
      else {
        $abouterror = 'sd ';
      }

Bet vai man ir kaut kas about sekcija, vai nav vienalga rādas 

 

68JoehRVRraWdxtIkrrVQw.png

 

A15k8YWGRb_NBiwB5lNcAg.png

 

kur ir problēma?

 

Share this post


Link to post
Share on other sites

Problēma ir tajā, ka isset() pārbauda vai mainīgais ir izveidots un saturs vērtību. Tavā gadījumā, $about, visticamāk, ka satur tukšu stringu nevis null vērtību. Līdz ar to isset($about) = true, jo ari tukšs string ir vērtība.

 

if (isset($about) && trim($about) !== '') { //$about eksistē }

vai

if (!empty(trim($about))) { //$about eksistē }

Edited by .bRass
  • Upvote 1

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.