Hi, I am having trouble echoing something into a url.

The code I've got is:

<?php
$code = "kooks";
echo '<a href="http://website.com/'$code'">The Kooks</a>'; ?>

But I get the message: Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /hermes/web11b/b146/moo.3finking/unsignedgigs/test.php on line 3

Thanks for your help

Recommended Answers

All 3 Replies

hey,
it shld be

<?php
$code="kooks";
echo "<a href=\"http://website.com/$code\">The Kooks </a>";

or

<?php 
$code="kooks";
?>
<a href="http://website.com/<?php echo $code; ?>">The Kooks</a>

Either use:

echo '<a href="http://website.com/' . $code . '">The Kooks</a>';

or:

echo "<a href=\"http://website.com/$code\">The Kooks</a>";

Thanks, I am slowly getting the hand of this...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.