...

View Full Version : php in php?



VietBoyVS
01-13-2004, 07:37 AM
<?php
$name1 = "d1.html";
$title1 = "a";
?>

<?php
echo "
<table width="680" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="338"><div align="center">Title</div></td>
<td width="342"><div align="center"></div></td>
</tr>
<tr>
<td><?php echo $title1 ?>&nbsp;</td>
<td><a href="<?php echo $name1 ?>">NAME</a>&nbsp;</td>
</tr>
";
?>



Parse error: parse error, expecting `','' or `';'' in name.php on line 8; any way i can fix this?

xxxemptyxxx
01-13-2004, 08:34 AM
i dont see why you need that <? ?> in the link, when you already have one around the table(which covers the whole table i think)

but im more than likely wrong cause im a noob at php :(

raf
01-13-2004, 10:35 AM
You can not use double quotes (") inside adouble-quoted string, unless you escape them (like \"). Try


<?php
$name1 = "d1.html";
$title1 = "a";
echo ('<table width="680" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="338"><div align="center">Title</div></td>
<td width="342"><div align="center"></div></td>
</tr>
<tr>
<td>' . $title1 . '&nbsp;</td>
<td><a href="'. $name1 .'">NAME</a>&nbsp;</td>
</tr>');
?>

Spookster
01-13-2004, 05:58 PM
Or an easier way would be to just not put everything in a string.




<?php
$name1 = "d1.html";
$title1 = "a";
?>

<table width="680" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="338"><div align="center">Title</div></td>
<td width="342"><div align="center"></div></td>
</tr>
<tr>
<td><?php echo $title1; ?>&nbsp;</td>
<td><a href="<?php echo $name1; ?>">NAME</a>&nbsp;</td>
</tr>



You don't have to echo everything using PHP. Just the parts that need it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum