[thelist] PHP tip

rudy r937 at interlog.com
Tue Feb 4 14:50:00 CST 2003


> In the case of empty strings, I can also proof on the client side by
> inserting NULL into a field before it is submitted.

that might work, and it might not

when you prepare the sql insert statement on the server side, you'll have to
catch those values anyway, so that you don't automatically enclose them in
quotes, and in that case, you might as well detect the empty field instead

for example, the following will work, but it's wrong --

    insert into foo ( bar1, barx )
      values ( 937, 'NULL' )

and it would not, of course, work if barx is a numeric field

the following is the correct way to insert a NULL --

    insert into foo ( bar1, barx )
      values ( 937, NULL )

actually, a better way is this --

    insert into foo ( bar1 )
      values ( 937 )

because you do not supply a value for barx, it gets a NULL

assuming, of course, that it's nullable in the first place

shawn's array_walk() sounds like it might allow you to do this tweaking
(i'm not sure because i don't do php)


rudy




More information about the thelist mailing list