Okay, so instead I should probably use: if($due_date != "") $insert2.=", due_date='$due_date'"; Instead of using empty() On 11/2/07, Nathan Nobbe <quickshiftin@xxxxxxxxx> wrote: > > On 11/2/07, Dan Shirah <mrsquash2@xxxxxxxxx> wrote: > > > > TGIF!! > > > > I have an insert statement that checks to see if a condition is met. If > > it > > is, then it adds that value to the insert statement. However, when I > > try to > > run it I get the error: Can't use function return value in write context > > > > > > Below is a sample of what I am using which gives me the error(The error > > occurs while trying to insert the "due_date") > > > > $insert2 = "INSERT INTO misc_service_payment_request SET"; > > if(empty($_POST['max_id'])) { > > $insert2.=" id = scope_identity(),"; > > } else { > > $insert2.=" id = '$max_id',"; > > } > > if(!empty(trim('$due_date')) > > $insert2.=", due_date='$due_date'"; > > mssql_query($insert2) or die ("Query failed: <br > > />".mssql_get_last_message()); > > > > Any ideas? > > > > > dont call trim() as an argument to empty(); it doesnt work that way. > see the manual <http://us.php.net/manual/en/function.empty.php>: > Note: empty() only checks variables as anything else will result in a > parse error. In other words, the following will not work: > empty(trim($name)). > > -nathan >