Echoing an apostrophe in a variable...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Hebbs
Forum Commoner
Posts: 43
Joined: Mon Apr 22, 2002 9:34 pm
Location: Perth, Western Australia

Echoing an apostrophe in a variable...

Post by Hebbs »

I cant quite get my head around this one.

I have a variable that is a name with an apostrophe in eg O'Grady.

When I echo the value ($g_last) within the script generally its OK,

when I try the following in a normal table I only get the O returned:

Code: Select all

<TD>Surname:</TD>
<TD><INPUT TYPE='text' NAME='surname' VALUE='<?php echo("$g_last") ?>' SIZE='40' MAXLENGTH='20' READONLY></TD>
Maybe its just the late hour.....

Hebbs
Hebbs
Forum Commoner
Posts: 43
Joined: Mon Apr 22, 2002 9:34 pm
Location: Perth, Western Australia

I think it must be the hour...

Post by Hebbs »

I no sooner posted the bl**dy thing and relased it was all in the quotes.

Replaced the single quotes of the html with doubles and fixed it.

Oh the shame! :oops:

Hebbs
Post Reply