I tried it like this

$skrit = $row['lvl']; if ($skrit == 'NULL') { #Если в поле с уровнем пусто то выводим что скрыт $persoff = 'Персонаж скрыт'; } else { #если не пусто то выводим значение из базы.. $persoff = $row['lvl']; } 
  • And how do you get the value of $ row? In the table, the lvl field is NULL? - cheops

1 answer 1

The string 'NULL' has nothing to do with the "null value", so that would not be meant by that.

A standard check for "empty value" in PHP is simply a casting of a variable to a boolean type, that is, substituting it into if directly

 if ($row['lvl']) { $persoff = $row['lvl']; } else { $persoff = 'Персонаж скрыт'; } 

If the condition does not work, then the point is not in the verification method, but in something else: a curved code, typos, incorrect data in the database, etc. To solve the problem in this case, you need to fix your code. First of all, look at what exactly is in the $row['lvl'] variable, using the var_dump() function. If there is really empty - then check the code that goes below the conditions.

  • Thank you very much))) it works))) now one less problem) - Konstantin