Parse Error

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
AnsonM
Forum Commoner
Posts: 72
Joined: Thu Sep 25, 2003 7:21 am

Parse Error

Post 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>
?>
AnsonM
Forum Commoner
Posts: 72
Joined: Thu Sep 25, 2003 7:21 am

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
AnsonM
Forum Commoner
Posts: 72
Joined: Thu Sep 25, 2003 7:21 am

Post by AnsonM »

oh.. i see what you mean... ill try to fix the script now... thanks :)
Post Reply