Re: can't work out the syntax error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/4/06, Brad Bonkoski <bbonkoski@xxxxxxxxxxxxxx> 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux