Hi everyone,

I'm trying to test a page with some php in it but I'm getting the following error:

Parse error: syntax error, unexpected T_ECHO in /Applications/MAMP/htdocs/newsite/admin/add_article.php on line 98

Line 98 is this line:

                <td class="right"><textarea name="article" id="article"><?php (isset($_POST['article'])) echo $_POST['article']; ?></textarea></td>

I wondered if someone could tell me what the error means or how to fix it?

Below is a larger block of surrounding code if it helps to troubleshoot.

Thanks for any help.

<body onload="P7_initPM(1,8,1,-20,10)">
<?php
if (isset($error)) {
  foreach ($error as $message) {
    echo '<p class="warning">'.$message.'</p>';
	}
  }
if(get_magic_quotes_gpc()) {
	foreach ($_POST as $key => $value) {
		$temp = stripslashes($value);
		$_POST[$key] = $temp;
		}
	}
?>
<div class="shadow">
  <div id="frame">
    <div id="header"> 
      <h3><img src="../images/phone.gif" alt="" />Call for an appointment: (02) 000 0000</h3>
	</div>
	  <div id="navtop">
	    <!--<ul id="p7PMnav">
          <li><a href="../index.php">Home</a></li>
	      <li><a href="../about_us.php">About Us</a></li>
	      <li><a href="../downloads.php">Downloads</a></li>
	      <li><a href="../price_list.php">Price List</a></li>
	      <li class="recommend"><a href="../rec_Practitioners.php" class="recommend">Recommended Practitioners</a></li>
	      <li><a href="../contact.php" id="noborder">Contact Us</a></li>-->
	      <!--[if lte IE 6]><style>#p7PMnav a{height:1em;}#p7PMnav li{height:1em;}#p7PMnav ul li{float:left;clear:both;width:100%}</style><![endif]-->
	      <!--[if IE 6]><style>#p7PMnav ul li{clear:none;}</style><![endif]-->
        <!--</ul>-->
	  </div>
	  <div id="enclose">
	    <div id="leftside"><!-- InstanceBeginEditable name="Content" -->
        <div id="columnMainInner">
	        <h1>Add an article  </h1>

		<form method="POST" name="addArticle" id="addArticle" action="">
		<table>
          <tr>
            <td class="label">Title</td>
            <td class="right"><input value="<?php if (isset($_POST['title'])) echo $_POST['title']; ?>" type="text" name="title" id="title" class="widebox" /></td>
          </tr>
          <tr>
            <td class="label">Author</td>
            <td class="right"><select name="author" id="author">
            </select>
            </td>
          </tr>
          <tr>
            <td class="label">Publication date </td>
            <td class="right"><input value="<?php if (isset($_POST['pub_date'])) echo $_POST['pub_date']; ?>" name="pub_date" type="text" id="pub_date" /></td>
          </tr>
          <tr>
            <td class="label">Delete article </td>
            <td class="right">No 
  <input name="kill_article" type="radio" value="N" checked="checked" /> 
  Yes 
  <input name="kill_article" type="radio" value="Y" /></td>
          </tr>
          <tr>
            <td class="label">Article</td>
            <td class="right"><textarea name="article" id="article"><?php (isset($_POST['article'])) echo $_POST['article']; ?></textarea></td>
          </tr>
          <tr>
            <td class="label">&nbsp;</td>
            <td class="right"><input type="submit" name="Submit" value="Submit" /></td>
          </tr>
        </table>
        </form>
    </div>
	    <!-- InstanceEndEditable -->
      <div id="columnLeft">
		    <ul>
		      	  <li><a href="admin_home.php">Admin Home</a></li>
			      <li><a href="add_user.php">Add  administrator</a></li>
			      <li><a href="add_article.php">Add article</a></li>
			      <li><a href="list_articles.php">List articles</a></li>
				  <li><a href="add_author.php">Add author</a></li>
			      <li><a href="list_authors.php">List authors</a></li>
			      <li><a href="list_subscribers.php">List subscribers</a></li>
	    </ul>
	<p>&nbsp; </p>
	<p>&nbsp; </p>
	<p>&nbsp; </p>
	<p>&nbsp; </p>
      </div>
    </div><div class="clear"></div>
  </div>
  <div id="footerinner"> © copyright 2008. All Rights Reserved  <!--&nbsp;|&nbsp; <a href="../terms_and_conditions.php">Terms and Conditions</a>  &nbsp;| &nbsp; <a href="../privacy_policy.php">Privacy Policy</a>  &nbsp; |&nbsp;  <a href="../contact.php">Contact Us</a>--></div>
  </div>
</div>
</body>
<!-- InstanceEnd --></html>

    On line 98, you don't define an "if" construct, you just evaluate whether the variable isset. You need to do it in one of two ways:

    Normal way:

    <?php if(isset($_POST['article'])) { echo $_POST['article']; } ?>

    Ternary Syntax:

    <?php echo (isset($_POST) ? $_POST['article'] : ''); ?>

    The ternary syntax is easy to understand:
    expression to evalueate ? value if true : value if false;

      Perfect - thanks so much for your help.

        Don't forget to mark this as resolved if it is.

          Write a Reply...