Welcome to www.HAS.lv - programmējam HTML.

Register now to gain access to all of our features. Once registered and logged in, you will be able to contribute to this site by submitting your own content or replying to existing content. You'll be able to customize your profile, receive reputation points as a reward for submitting content, while also communicating with other members via your own private inbox, plus much more! This message will be removed once you have signed in.

Sign in to follow this  
Followers 0
inadatequate

PHP isset

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?

 

0

Share this post


Link to post
Share on other sites

Posted (edited)

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
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  
Followers 0