Re: oddity with insert multiple input fields to multipletables
| From: | Jason Wong | Date: | Sun, 18 Aug 2002 07:40:27 +0000 |
| Subject: | Re: oddity with insert multiple input fields to multipletables | ||
| References: | 1 2 3 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-21209@lists.php.net to get a copy of this message | ||
On Sunday 18 August 2002 13:40, Chip Wiegand wrote:
> Okay, so I tried this -
>
> if ($date_am || $exercise_am || $reps_am !== "")
> {
> $sql_am = "insert into absmachine (today,exercise,reps,comments)
> values
> ('$date_am','$exercise_am','$reps_am','$comments_am')";
> mysql_query($sql_am) or die ("Error in this query >>$sql<< : "
> .mysql_error());
> }
[snip]
> But I still get empty rows inserted into the tables.
|| means OR
You want to insert a value when:
1) $date_am has a value AND
2) $exercise_am has a value AND
3) $reps_am is not an empty string
so use AND or && instead of ||.
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
A couch is as good as a chair.
*/