jimmi8 Posted December 16, 2006 Share Posted December 16, 2006 Hi,I have these two scripts. Basically the first one prints out a list of blog titles with a link through to another page which will enable the user to edit the blog post. The first script is here and works fine:[code]<?php include ('header.inc');?><ul> <?phprequire_once ('mysql_connect.php'); $sql = "SELECT * FROM entries ORDER BY date_submitted"; $sqlresult = mysql_query($sql); while ($row = mysql_fetch_array($sqlresult)){?><li><a class="body" href="editentry.php?blog_id=<?php echo $row['blog_id']; ?>"><?php echo $row['title']; ?></a></li><?php }include ('footer.inc');?></ul>[/code]Now the second script is using the GET variable at the top of the page to find out which blog we're editing. I cant spot a problem with the code but i get this error:[18-Jun-2006 22:40:55] PHP Parse error: syntax error, unexpected $end in /Applications/MAMP/htdocs/editentry.php on line 76Anyways heres the code. Im new to php but have spent hours trying to debug to no avail. Perhaps my method of using the id in the url and using GET to, well get the id is not the correct method[code]<?phpinclude ('header.inc');if(isset($_GET['blog_id'])) { $blog_id = $_GET['blog_id'];}else { $blog_id = NULL; echo 'Please specify a section';} $sql = "SELECT * FROM entries WHERE blog_id = $blog_id"; $result = mysql_query($sql); $row = mysql_fetch_array($result); while($row) { $title = $row['title']; $body = $row['body'];?><div id="main"> <form action="<?php echo $_SERVER['PHP_SELF']; ?>?blog_id=<?php echo $blog_id; ?>" name="input" method="post"> <input type="text" size="50" name="title" maxlength="200" value="<?php echo $title; ?>" /> <input type="text" size="50" name="body" maxlength="200" value="<?php echo $body; ?>"/> <input class="bodyform" type="submit" name="submitedit" value="SUBMIT"/></form><?php } ?> <?phpif (isset($_POST['submitedit'])) {//form validationif (strlen($_POST ['title']) > 0) { $title = $_POST ['title']; } else { $title = NULL; } if (strlen($_POST['body']) > 0) { $body = $_POST['body']; } else { $body = NULL; }if($title && $body) { //update the database with edited data $sql = "UPDATE entries SET title = $title, body = $body WHERE blog_id = $blog_id"; $result = mysql_query($sql);}else { echo 'please fill out form fields';}include ('footer.inc');?>[/code]any ideas?!? Link to comment https://forums.phpfreaks.com/topic/30915-these-two-scripts-dont-seem-to-work-with-each-other/ Share on other sites More sharing options...
trq Posted December 16, 2006 Share Posted December 16, 2006 Your missing the closing } to your while().[code=php:0]while($row) { $title = $row['title']; $body = $row['body'];}[/code] Link to comment https://forums.phpfreaks.com/topic/30915-these-two-scripts-dont-seem-to-work-with-each-other/#findComment-142640 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.