Help
-
Search
-
Members
-
Calendar
Full Version:
staement
HTMLHelp Forums
>
Programming
>
Server-side Scripting
tudsy
Aug 12 2016, 01:51 AM
Hi
I have defined $person above this statement:
<input type='submit' name='submit' value='Click to view '.<?php echo $person ?>.'.'s '>
I was wondering what is wrong with this statement. Any help would be appreciated.
Thanks.
Christian J
Aug 12 2016, 07:25 AM
Is it already part of an echo? If so you can't nest another echo inside it. The period signs look wrong either way.
CharlesEF
Aug 12 2016, 01:12 PM
Looks to me like you have a syntax error. Change this line:
CODE
<input type='submit' name='submit' value='Click to view '.<?php echo $person ?>.'.'s '>
To this:
CODE
<input type='submit' name='submit' value='Click to view '<?php echo "{$person}'s " ?>>
Christian J
Aug 12 2016, 01:52 PM
The single quote and period sign before the PHP code still looks wrong to me (assuming $person is part of the INPUT value).
With PHP embedded in normal HTML I'd do it like this:
CODE
<input type="submit" name="submit" value="Click to view <?php echo $person ?>'s">
...or if all the HTML code is printed by PHP, like this:
CODE
echo '<input type="submit" name="submit" value="Click to view '.$person.'\'s">';
CharlesEF
Aug 12 2016, 02:16 PM
Yes, that 1 period slipped past me during my edit. I have fixed it now. I just followed the OP's format but your format would work also.
Christian J
Aug 12 2016, 02:53 PM
There's an extra single quote as well, which will close the VALUE attribute value.
CharlesEF
Aug 12 2016, 07:21 PM
Boy, my eye is really going bad. Anyway, I would suggest the OP follow your example:
CODE
<input type="submit" name="submit" value="Click to view <?php echo $person;?>'s">
I always use double quotes with HTML attributes. I think the OP should also.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please
click here
.
Invision Power Board © 2001-2024
Invision Power Services, Inc.