Re: oddity with insert multiple input fields to multipletables

From: Date: Mon, 19 Aug 2002 03:04:32 +0000
Subject: Re: oddity with insert multiple input fields to multipletables
References: 1 2 3 4 5  Groups: php.db 
Request: Send a blank email to php-db+get-21224@lists.php.net to get a copy of this message
On Sun, 2002-08-18 at 21:21, Chip Wiegand wrote: > On Sun, 2002-08-18 at 01:20, Joni Järvinen wrote: > > > if (!isnull($date_am || $exercise_am || $reps_am)) then > > > mysql_query($sql_am) or die > > > ("Error in this query >>$sql<< : " .mysql_error()); > > > > Try: > > > > if(!isnull($date_am) && !isnull($exercise_am) && !isnull($reps_am)) > > > > This should IMO work :) > > > > -Joni- > > I was looking at the php manual and noticed the function is actually > is_null, not isnull. Yet it still does not work, I tried this: > > $sql_am = "insert into absmachine (today,exercise,reps,comments) > values > ('$date_am','$exercise_am','$reps_am','$comments_am')"; > if(!is_null($date_am)) > mysql_query($sql_am) or die ("Error in this query >>$sql<< : " > .mysql_error()); > > And it still inserts the row no matter what, as long as submit is > pressed a row is written, with or without any data. > Try unset($sql_am) as the result of your is_null() test. you should get a warning but not a fat error Otherwise you will have to seperate the inserts I think into 4 diff queries unless you put the variables to input into an array and then iterate through the array. Yeah finally got to use iterate!!! too much reading of "Flatterland, just like Flatland only more so" John

« previous php.db (#21224) next »