PHP check and replace empty value before insert to MySQL database -


I need to check the empty data value before inserting it into the database. I have two ways:

< P> one:

  $ comment = (below ($ _ POST ['regcomment']))? '0': $ _POST ['Prompt']; $ Sql ​​= Update ("Update" option. "SET comment =?", $ Comment);  

two:

  $ sql = update ("UPDATE" option. "SET comment =?", (Empty ($ _ POST ['regcomment' ])) '' 0 ': $ _POST [' Reconnect ']);  

How better is it ?!

This is primarily opinion-based. Both of these lead to the same result, the only difference is that in the second version you do not have the result of a turner-statement in a variable, then you need it.

Triangle-statement and function-calls are split in the first version, so it is more readable.


Comments