The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> staement
tudsy
post Aug 12 2016, 01:51 AM
Post #1


Advanced Member
****

Group: Members
Posts: 246
Joined: 30-September 14
Member No.: 21,611



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 12 2016, 07:25 AM
Post #2


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



Is it already part of an echo? If so you can't nest another echo inside it. The period signs look wrong either way.

This post has been edited by Christian J: Aug 12 2016, 09:03 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Aug 12 2016, 01:12 PM
Post #3


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



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 " ?>>


This post has been edited by CharlesEF: Aug 12 2016, 02:12 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 12 2016, 01:52 PM
Post #4


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



The single quote and period sign before the PHP code still looks wrong to me (assuming $person is part of the INPUT value). unsure.gif

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">';
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Aug 12 2016, 02:16 PM
Post #5


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Aug 12 2016, 02:53 PM
Post #6


.
********

Group: WDG Moderators
Posts: 9,653
Joined: 10-August 06
Member No.: 7



There's an extra single quote as well, which will close the VALUE attribute value.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
CharlesEF
post Aug 12 2016, 07:21 PM
Post #7


Programming Fanatic
********

Group: Members
Posts: 1,981
Joined: 27-April 13
From: Edinburg, Texas
Member No.: 19,088



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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th April 2024 - 09:50 AM