APD Toronto
asked on
Fatal error: Can't use function return value in write context
Hi Experts,
Why do I keep getting:
Fatal error: Can't use function return value in write context
...when I:
Thank you.
Why do I keep getting:
Fatal error: Can't use function return value in write context
...when I:
if(isset($_POST["email"]) || !empty(trim($_POST["email"])))
{
$strEmail = $_POST["email"];
}
else
{
$err = 1;
}
Thank you.
if(isset($_POST["email"]) && !empty(trim($_POST["email" ])))
ASKER
makes logical sense - thanks, but same error
What is the whole function
ASKER
nothing too complex... The error is at Li.40
<?php
$submit = '';
$err = 0;
$strName = '';
$strEmail = '';
$strSelect = '';
$strMessage = '';
if(isset($_GET["submit"]))
{
$submit = $_GET["submit"];
}
if($submit == '')
{
displayForm();
}
else
{
validate();
}
function validate()
{
global $err;
global $strName;
global $strEmail;
global $strSelect;
global $strMessage;
if(isset($_POST["name"]))
{
$strName = $_POST["name"];
}
if(isset($_POST["email"]) && !empty(trim($_POST["email"])))
{
$strEmail = $_POST["email"];
}
else
{
$err = 1;
}
if(isset($_POST["selection"]))
{
$strSelect = $_POST["selection"];
}
else
{
$err = 1;
}
if(isset($_POST["message"]) && !empty(trim($_POST["message"])))
{
$strMessage = $_POST["message"];
}
else
{
$err = 1;
}
if($err = 1)
{
displayForm();
}
else
{
sendEmail();
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
As a general rule, compound statements with multiple function calls in the same line of code are a path to confusion. I believe this statement is causing the problem:
empty(trim($_POST["email"] ))
Try something more like this:
$email = trim($_POST['email']);
if (empty($email)) /* DO SOMETHING */
Long ago, PHP allowed this sort of thing, but it's not allowed any more. That's one of the risks of getting old bits of code from the internet - you don't really know if it works. Maybe it used to work and doesn't any more.
empty(trim($_POST["email"]
Try something more like this:
$email = trim($_POST['email']);
if (empty($email)) /* DO SOMETHING */
Long ago, PHP allowed this sort of thing, but it's not allowed any more. That's one of the risks of getting old bits of code from the internet - you don't really know if it works. Maybe it used to work and doesn't any more.