On Jul 8, 2010, at 10:09 AM, Ashley Sheridan wrote:

thanks Ash,

I figure it out. I was not entering the full year.

date('y-m-d',strtotime($fval))
needed to be

date('o-m-d',strtotime($fval))

Duh ;-)

Thanks,

Don

On Wed, 2010-07-07 at 13:28 -0700, Don Wieland wrote:

Hello all,

I am processing an array to build an INSERT string in PHP. The code
below I build an a separate array for the TARGET fields and the VALUES.

I am trying to trap for a NULL ENTRY in a Date Input Field. Date
fields are identified with: $ffield['s']=='/'

I tried to add the "&& !empty($fval)" to the test but it is giving my
an unexpected results. In my case, I have a Data of Birth field that
keeps populating in the future:  So 1941-06-16  inserts in the DB as
2041-06-16.

foreach($form_fields as $ffield){
                        $fval = is_array($ffield['f'])?joinFields($ffield['s'],
$ffield['f']):$_POST[$ffield['f']];
                        $query_values[] = 
"'".mysql_real_escape_string($ffield['s']=='/'
&& !empty($fval) ?date('y-m-d',strtotime($fval)):$fval)."'";
                }

Will anyone point out the problem with this CODE?

Don Wieland


I can't see anything immediately wrong, but the tertiary operators here mixed in with the mysql_ function and string concatenation don't make for easy reading! Maybe add some brackets to partition things off a bit to make the code easier on the eye. :p

Have you tried echo'ing out the queries to see if they actually look well-formed? One place it could fall over is if the values you're using in it aren't well formed.

Lastly, you're using a $_POST field directly in your query if the first tertiary if/else fails. You should at the very least validate it to make sure it's in the form you expect, which has to at least be something that can be parsed and processed by strtotime() which you're using in your example.

Thanks,
Ash
http://www.ashleysheridan.co.uk

Don Wieland
D W   D a t a   C o n c e p t s
~~~~~~~~~~~~~~~~~~~~~~~~~
d...@dwdataconcepts.com
Direct Line - (949) 305-2771

Integrated data solutions to fit your business needs.

Need assistance in dialing in your FileMaker solution? Check out our Developer Support Plan at:
http://www.dwdataconcepts.com/DevSup.html

Appointment 1.0v9 - Powerful Appointment Scheduling for FileMaker Pro 9 or higher
http://www.appointment10.com

For a quick overview -
http://www.appointment10.com/Appt10_Promo/Overview.html

Reply via email to