Re: can't work out the syntax error

From: Date: Thu, 04 May 2006 13:28:24 +0000
Subject: Re: can't work out the syntax error
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-235510@lists.php.net to get a copy of this message
On 5/4/06, Brad Bonkoski <bbonkoski@mediaguide.com> wrote:
try this: echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\">
            <A
HREF=\"javascript:open_window('".$_SERVER['PHP_SELF']."?action=view_record&userid=$userid');\">View</A> -------------------------------------------^-------------------------------^ concatenate the $_SERVER variable to the string...
Or wrap the variables with curly braces so that PHP knows what's a variable and what's not: [php] echo "<TD WIDTH=\"25%\" ALIGN=\"CENTER\"> <A HREF=\"javascript:open_window('{$_SERVER['PHP_SELF']}?action=view_record&userid=$userid');\">View</A> [/php] Personally, I get tired (and confused) when having to escape all of those quotes like in the string you're trying to echo above. Perhaps you'd consider HEREDOC as an alternative approach: [php] echo<<<HEREDOC <TD WIDTH="25%" ALIGN="CENTER"> <A HREF="javascript:open_window('{$_SERVER['PHP_SELF']}?action=view_record&userid=$userid');">View</A> HEREDOC; [/php] If you haven't read about HEREDOC before, RTFM because there are some rules you should know about it... HTH, John W

« previous php.general (#235510) next »