supermerc Posted December 24, 2006 Share Posted December 24, 2006 im getting this error: Parse error: syntax error, unexpected $end in /home/xgame/public_html/random/edit.php on line 90with this code [code]<?php//The following PHP script allows you to edit the//contents of your MySQL table.//Connecting to the MySQL databaserequire('dbconnect.php');//Should we show a single item or a list?if($_POST['edit']) {//Simplifying the variables.$id = $_POST['id'];$title = $_POST['title'];$author = $_POST['author'];$date = $_POST['date'];//trim() strips white space from the beginning and end of a line.$date = trim($date);$content = $_POST['content'];//Checks for empty fields or invalid date.if((empty($title)) OR (empty($author)) OR (empty($date)) OR (empty($content))) {echo "<center><strong>Please fill in all fields!</strong></center>"; } else {//explode() separates the date by the '/' character and outputs it to an array.$explode_date = explode('/', $date);//checkdate() returns FALSE if the date is invalid.$check_date = checkdate($explode_date[0], $explode_date[1], $explode_date[2]);if($check_date == false) {echo "<center><strong>Invalid date entered!</strong></center>"; } else {//htmlspecialchars() converts special characters into HTML entities.$title = htmlspecialchars($title);$author = htmlspecialchars($author);//The MySQL query which will update the content in the table.$query = "UPDATE news SET title = '$title', author = '$author', date = '$date', content = '$content' WHERE ID = '$id'";//Execute the query.$result = mysql_query($query) or die(mysql_error());echo "<center><strong>News item modified!</strong></center>"; } } } elseif($_GET['action'] == "edit") {//Display a single result.$id = $_GET['id'];//The MySQL query. Select all from the table news where the ID equals the id sent in URL.$query = "SELECT * FROM news WHERE ID='$id'";//Executing the query.$result = mysql_query($query) or die(mysql_error());//Displaying the results of the query.while ($row = mysql_fetch_array($result)) {//extract() takes an associative array and treats the keys as variable names and values as variable values.extract($row);?><form method="post" action="edit.php"><table align="center"><tr><td align="right">Title:</td><td><input type="text" name="title" value="<?php echo "$title"; ?>" maxlength="250" /></td></tr><tr><td align="right">Author:</td><td><input type="text" name="author" value="<?php echo "$author"; ?>" maxlength="250" /></td></tr><tr><td align="right">Date:</td><td><input type="text" name="date" value="<?php echo "$date"; ?>" maxlength="10" /></td></tr><tr><td align="right">Content:</td><td><textarea name="content" cols="50" rows="10"><?php echo "$content"; ?></textarea></td></tr><tr><td> </td><td><input type="hidden" name="id" value="<?php echo "$ID"; ?>" /><input type="submit" name="edit" value="Modify" /><input type="reset" name="reset" value="Reset" /></td></tr></table></form><? } } else {//Since we're not displaying a single result,//we're going to display a list of results.//The MySQl query. Selects all from the table news.$query = "SELECT * FROM news ORDER BY ID DESC";//Execute the query.$result = mysql_query($query) or die(mysql_error());while ($row = mysql_fetch_array($result)) {//extract() takes an associative array and treats the keys as variable names and values as variable values.extract($row);echo '<table><tr><td><strong><a href="edit.php?action=edit&id='.$ID.'">'.$title.'</a></strong></td></tr><tr><td><small>Written by '.$author.' on '.$date.'</small></td></tr><tr><td><strong><a href="delete.php?id='.$ID.'">DELETE</a></strong></td></tr>';?>[/code]I really cant find the issue Link to comment https://forums.phpfreaks.com/topic/31768-solved-parse-error/ Share on other sites More sharing options...
kenrbnsn Posted December 24, 2006 Share Posted December 24, 2006 You're missing at least 2 closing "}" at the end of your script. If you employ proper indentation in your script, this would have been much easier to find.Ken Link to comment https://forums.phpfreaks.com/topic/31768-solved-parse-error/#findComment-147311 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.