Re: Function return
| From: | Nathan Nobbe | Date: | Fri, 02 Nov 2007 14:37:53 +0000 |
| Subject: | Re: Function return | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263973@lists.php.net to get a copy of this message | ||
On 11/2/07, Dan Shirah <mrsquash2@gmail.com> 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