Hi there,
At present, I'm using the variables $nameerror and $_POST['name'], in the middle of string concatenation, but this is throwing up errors on the occasions where these variables are undefined. Here is my code at present:
<input type=\"text\" name=\"name\" MAXLENGTH=\"50\" value=\"". htmlentities($_POST['name']) ."\" />" . $nameerror .
I now want to change this code to only display $nameerror and $_POST['name'] if they have been set and are not empty.
I've searched around online and it seems that IF statements can't be used in the middle of string concatenation, so conditional statements using ? and : are recommended instead. However, every time I try conditional statements, PHP seems to throw up some sort of error.
I've tried all sorts of combinations, including:
$nameerror ? $nameerror : FALSE $nameerror ? $nameerror : "" isset($nameerror) ? $nameerror : FALSE isset($nameerror) ? $nameerror : "" empty($nameerror) ? FALSE : $nameerror empty($nameerror) ? "" : $nameerror
None of these work. Some throw up error messages. Other stop the page from fully loading, meaning elements are missing.
Can someone advise me on what I'm doing wrong here as I've been wracking my head for hours and still can't work it out.
Thanks.