Skip to main content
Participant
April 27, 2007
Question

If, else statement

  • April 27, 2007
  • 2 replies
  • 357 views
Hi guys

I'm still having problems with an if, elseif, else statement and cannot see the problem - can anybody help me out please. The error I get is "Parse error: syntax error, unexpected '<', expecting ',' or ';' in /webusers/lw6law/public_html/publications/admin/PublicationsSearchResults.php on line 111" - line 111 is the 7th line of the attached code.

Are there any other problems that someone can see.

Thanks
This topic has been closed for replies.

2 replies

Günter_Schenk
Inspiring
April 27, 2007
Hi,

well, you do have *lots* of home-made errors in there ;-)

1. please delete line 6:
$row_rs_pubsearch['pubtype']="journal";
you won´t need it, as you´re using it for the if - statement in the next line - and the syntax is wrong

2. as for the rest :: the problem is based on wrong syntax (e.g. the missing '...' and the fact that you can´t use nested <?php ... ?> statements in here) within your "echo" statements -- the syntax should be like this:

echo '<a href="journal_edit.php?recordID='.$row_rs_pubsearch['PubID'].'">Edit Publication</a>';

Does it help when changing your echo´s accordingly ?
Gaz-ukAuthor
Participant
April 27, 2007
Hi both

Many thanks for your help with this, it's now working - i've only just started to use php and have got into a muddle a fair bit, your help was excellent.

All the best
Gaz
Inspiring
April 27, 2007
Gaz-uk wrote:
> I'm still having problems with an if, elseif, else statement and cannot see
> the problem - can anybody help me out please. The error I get is "Parse error:
> syntax error, unexpected '<', expecting ',' or ';' in
> /webusers/lw6law/public_html/publications/admin/PublicationsSearchResults.php
> on line 111" - line 111 is the 7th line of the attached code.

You're attempting to nest PHP tags inside other PHP tags, which is
illegal and causing the parse error. Line 111 is only the first of many
such illegal nests. The following code should work:

<h1>Publication Search Results</h1>
<?php do { ?>
<p><?php echo $row_rs_pubsearch['PubID']; ?> / <?php echo
$row_rs_pubsearch['pubtype']; ?> / <?php echo $row_rs_pubsearch['pubyear'];
?><br>
<?php echo $row_rs_pubsearch['title']; ?><br>
<?php echo $row_rs_pubsearch['authors']; ?><br>
$row_rs_pubsearch['pubtype']="journal";
<?php if ($row_rs_pubsearch['pubtype'] == "journal") { ?>
<a href="journal_edit.php?recordID=<?php echo
$row_rs_pubsearch['PubID']; ?>">Edit Publication</a>
<?php } elseif ($row_rs_pubsearch['pubtype'] == "book") { ?>
<a href="book_edit.php?recordID=<?php echo $row_rs_pubsearch['PubID'];
?>">Edit Publication</a>
<?php } elseif ($row_rs_pubsearch['pubtype'] == "chapter") { ?>
<a href="chapter_edit.php?recordID=<?php echo
$row_rs_pubsearch['PubID']; ?>">Edit Publication</a>
<?php } elseif ($row_rs_pubsearch['pubtype'] == "report" { ?>
<a href="report_edit.php?recordID=<?php echo
$row_rs_pubsearch['PubID']; ?>">Edit Publication</a>
<?php } else { ?>
<a href="paper_edit.php?recordID=<?php echo $row_rs_pubsearch['PubID'];
?>">Edit Publication</a>
<?php } ?>
<?php } while ($row_rs_pubsearch = mysql_fetch_assoc($rs_pubsearch)); ?>
<p> </p>
</body>

--
David Powers, Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/