0

I have a table in my database and wanted to have empty values that will be updated later on. I dont want the values to be defined as null and when I use None as the default I get a database error when trying to enter values into the database. Help I dont want to use Null. Im running mysql on phpmyadmin.

Is there a configuration on phpmyadmin that would allow empty values to be passed or allow empty strings (without using the NULL)?

Shadow
  • 33,525
  • 10
  • 51
  • 64
Sammy Gituko
  • 11
  • 1
  • 5

2 Answers2

0

Use NOT NULL when defining the column. Or, in phpmyadmin, simply don't check the NULL checkbox.

Johannes
  • 64,305
  • 18
  • 73
  • 130
  • Not null means there has to be a value. I just wanted an empty field that will be updated later on – Sammy Gituko Sep 29 '18 at 20:19
  • You can leave the field empty (= no value) – Johannes Sep 29 '18 at 20:20
  • When I leave as none it gives me an error that nothing has been passed on that field – Sammy Gituko Sep 29 '18 at 20:22
  • hmm - not here... – Johannes Sep 29 '18 at 20:22
  • Is there a configuration on the phpmyadmin that would allow empty values to be passed or allow empty strings? – Sammy Gituko Sep 29 '18 at 20:23
  • I never have a problem (i.e. get any error messages) when I simply ignore such a field in an insert query – Johannes Sep 29 '18 at 20:25
  • Maybe you should describe the situation where your problem actually pops up? Like, post the code of your query / form / whatever when "trying to enter values into the database". – Johannes Sep 29 '18 at 21:37
  • When NULL is unchecked this is the error: {PHP Fatal error: Uncaught PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'phone' cannot be null in /home1/collages/public_html/form-mailers.php:16} – infin80 May 19 '21 at 22:49
0

For varchar, text or blob fields You can use '' as an value.