Forum Moderators: coopster
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /home/binaries/public_html/pages/addnews.php on line 16
I know that its this piece of code as i have removed it and it runs correctly (i'm not sure how to use string, variables and php code inside of a echo statement, if anyone can explain it to me or link me that would be great.
Code:
echo '<form action='$_SERVER[PHP_SELF]' method="post">
<p><b>News Title :</b><br />
<input type="input" name="title" size="25" maxlength="60" value='if(isset($_POST[title])) echo $_POST[title]' /></p>
<p><b>Name :</b><br />
<input type="input" name="name" size="15" maxlength="35" value='if(isset($_POST[name])) echo $_POST[name]' /></p>
<p><b>Message :</b><br />
<textarea rows="7" cols="55" name="message">'if(isset($_POST["message"])) echo $_POST["message"]'</textarea></p>
<p><input type="submit" name="submit" value="Add News" /></p>
<input type="hidden" name="submitted" value="TRUE" /></p>
</form>';
where you have an echo used the <?php and ?> tags to close it off from the html
<form action='<?php $_SERVER[PHP_SELF]'?> method="post">
<p><b>News Title :</b><br />
<input type="input" name="title" size="25" maxlength="60" value="<?php if(isset($_POST[title])){echo $_POST[title];}?></p>"
<p><b>Name :</b><br />
<input type="input" name="name" size="15" maxlength="35" value="<?php if(isset($_POST[name])){echo $_POST[name];}?></p>
<p><b>Message :</b><br />
<textarea rows="7" cols="55" name="message"> <?php if(isset($_POST["message"])){echo $_POST["message"];}?></textarea></p>
<p><input type="submit" name="submit" value="Add News" /></p>
<input type="hidden" name="submitted" value="TRUE" /></p>
</form>';
or something similar..........
Example:
News Title : Has:
<?php if(isset($_POST[title])) echo $_POST[title]; ?> in the box along with the other two, Name and Message. How would this be fixed?
this works, but what are you trying to do anyways?
<form action="<?php echo $_SERVER[PHP_SELF];?>" method="post">
<p><b>News Title :</b><br>
<input type="input" name="title" size="25" maxlength="60" value="<?php if(isset($_POST['title'])){echo $_POST['title'];}?>"></p>
<p><b>Name :</b><br />
<input type="input" name="name" size="15" maxlength="35" value="<?php if(isset($_POST['name'])){echo $_POST['name'];}?>"></p>
<p><b>Message :</b><br />
<textarea rows="7" cols="55" name="message"><?php if(isset($_POST['message'])){echo $_POST['message'];}?></textarea></p>
<p><input type="submit" name="submit" value="Add News" /></p>
<input type="hidden" name="submitted" value="TRUE" /></p>
</form>