Codes here !
Moderators: macek, egami, gesf
I found out that even if you declare a column in a table in mysql as NOT NULL
it would still allow you to insert an empty string. ''.
how can I prevent this from happening in mysql?
I can always make the check in php, but, I want it to be in both ends.
Thank you in advance guys
- New php-forum User
- Posts: 87
- Joined: Wed May 16, 2012 4:17 pm
Technically you could do it with a trigger.
You would need to execute it in MySQL console or in PHPMyAdmin
- Code: Select all
CREATE TRIGGER <name of the trigger> BEFORE INSERT ON <name of table>
FOR EACH ROW BEGIN
IF NEW.<fieldname> = ''
SET NEW='Error: Cannot insert record empty value for <fieldname>';
- php-forum Fan User
- Posts: 981
- Joined: Thu Feb 17, 2011 6:52 am
- Location: Racine, WI
Return to mySQL & php coding
Who is online
Users browsing this forum: No registered users and 2 guests