Page 1 of 1

Parse Error

Posted: Thu Oct 02, 2003 8:22 pm
by AnsonM
Hey, Could anyone tell me whats wrong with this?

Code: Select all

<?php
		<td class="title"><b><? echo :: . $news['n_title'] :: Posted on: . $news['n_date'] By: . $news['n_user']; ?></b></td>
?>

Posted: Thu Oct 02, 2003 8:30 pm
by AnsonM

Code: Select all

Parse error: parse error, expecting `','' or `';'' in /home/eighth-d/public_html/anson/pages/dsp_index.php on line 10

Posted: Thu Oct 02, 2003 9:01 pm
by volka
<?php
<td class="title"><b>
that's not php code but static html. Therefor you have to either echo it or step out the php-block (not enter it)
<? echo :: . $news['n_title'] :: Posted on: . $news['n_date'] By: . $news['n_user']; ?>
if :: is a string literal you want to echo you have to quote it same with ':: Posted on', 'By', ...
Since you're already stepping in and out the php-blocks you might want to place all static output outside a php-block and only echo the dynamical parts, e.g.

Code: Select all

<?php
$popesRome = array(
		array('name'=>'Urban VI', 'reigned'=>'1378-1389'),
		array('name'=>'Bonifatius IX', 'reigned'=>'1389-1404'),
		array('name'=>'Innozenz VII', 'reigned'=>'1404-1406'),
		array('name'=>'Gregor XII', 'reigned'=>'1406-1415')
	);
?>
<html>
	<head><title>Great Western Schism</title></head>
	<body>
		<table border="1">
			<tr><th colspan="2">Popes Of Rome</th></tr>
<?php
foreach($popesRome as $pope) {
?>
			<tr>
				<td>pope <?php echo $pope['name']; ?></td>
				<td>reigned <?php echo $pope['reigned']; ?></td>
			</tr>
<?php			
}
?>
		</table>
	</body>
</html>
take a look at the colors the highlighter assigned to my script and then compare with yours

Posted: Thu Oct 02, 2003 9:55 pm
by AnsonM
oh.. i see what you mean... ill try to fix the script now... thanks :)