Can you display variable within a href="$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
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Can you display variable within a href="$variable"

Post by mikegotnaild »

Im getting 'Parse error: parse error, expecting `','' or `';'' in /www/n/naild/htdocs/localmm/modules/Bands_Showcase/index.php on line 36' And its because i put a variable inside a link. How could i do this? Heres my code: (I would also like to know how to list code in these forums with the highlited colors like i see here and there)

Code: Select all

<?

$query="SELECT * FROM nuke_bands";
$result=mysql_query($query);

$num=mysql_numrows($result);

mysql_close();

$i=0;
while ($i < $num) &#123;

$bandname=mysql_result($result,$i,"band_name");
$description=mysql_result($result,$i,"description");
$history=mysql_result($result,$i,"history");
$influences=mysql_result($result,$i,"influences");
$genra=mysql_result($result,$i,"genra");
$email=mysql_result($result,$i,"email");
$website=mysql_result($result,$i,"website");
?>

<br>Click&nbsp <a href="modules.php?name=Bands_Showcase&file=form">HERE</a>&nbsp to submit a band, upload your mp3 and image.<br>
<br>

<?
echo "<b>$bandname</b><br><br><b>Description:</b> $description<br><br><b>History:</b> $history<br><br><b>Influences:</b> $influences<br><br><b>E-mail:</b> $email<br><br><b>Website:</b> <a href="$website">$website</a><br><br><hr><br>";

++$i;
&#125;
?>
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Only error I got was

Code: Select all

<?php
echo "<b>$bandname</b><br><br><b>Description:</b> $description<br><br><b>History:</b> $history<br><br><b>Influences:</b> $influences<br><br><b>E-mail:</b> $email<br><br><b>Website:</b> <a href="$website">$website</a><br><br><hr><br>";
?>
to

Code: Select all

<?php
echo "<b>$bandname</b><br><br><b>Description:</b> $description<br><br><b>History:</b> $history<br><br><b>Influences:</b> $influences<br><br><b>E-mail:</b> $email<br><br><b>Website:</b> <a href="$website">$website</a><br><br><hr><br>";



?>
Get get the syntax.. simply instead of using the code button use the php button
Last edited by John Cartwright on Tue Feb 17, 2004 7:41 pm, edited 3 times in total.
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

OH this shows how newb i am lol. Slashes
mikegotnaild
Forum Contributor
Posts: 173
Joined: Sat Feb 14, 2004 5:59 pm

Post by mikegotnaild »

thanks
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

np
Post Reply