-2

I can't make the empty value to be checked as NULL in database instead of leaving an empty space when I am inserting a value.

I don't want to leave an empty/blank space for an entry when it has no value. So if there is no file selected, make that entry into NULL

Is it unnecessary to be in NULL?

if (empty($_FILES['logo']['name'])) {
  $code = NULL;
  } else {
}
Chris_00
  • 406
  • 6
  • 17

2 Answers2

0

It's a normal problem with null-able strings. For a quick solution, you can change your code to:

$code = NULL;
if( !empty($_FILES['logo']['name']) ){
 ...
}

For more details, you can check this question: MySQL and PHP - insert NULL rather than empty string

iMangas
  • 141
  • 2
0

$logo = (!empty($_FILES['logo']['name']) ? "logo" : "NULL");
try this

Kabir Safi
  • 87
  • 7