TGWSE_GY Posted August 17, 2009 Share Posted August 17, 2009 Hey guys, once again have 2 pages here, the first one news.php displays the articles that the user may edit and by clicking that button the article should be displayed in the following page, get_news.php. However for some reason the first button on news.php does not work but the other 3 buttons do. When the first button is clicked the news.php is reloaded rather then being forwarded to the get_news.php. news.php: <?php //Get database connectiong config include('config.php'); $tbl = "jamsmag_news"; //Get title from db $query = "SELECT * FROM $tbl"; $result = mysql_query($query) or (mysql_error()); while ($row = mysql_fetch_assoc($result)){ $id = $row['id']; $title = $row['title']; echo $title; echo "<form method=\"post\" action=\"maineditor.php?section=edit_get_news\"><input type=\"hidden\" value=\"$id\" name=\"id\" id=\"id\"><input type=\"submit\" value=\"EDIT ARTICLE\"></form>"; } ?> get_news.php: <?php //Get database connectiong config include('config.php'); $id = $_POST['id']; $tbl = "jamsmag_news"; //Get title from db $query = "SELECT * FROM $tbl WHERE id='$id'"; $results = mysql_query($query) or (mysql_error()); $resultsarray = mysql_fetch_assoc($results) or die(mysql_error()); $title = $resultsarray['title']; $article = $resultsarray['article']; $summary = $resultsarray['summary']; $search = "src=\"images"; $replace = "src=\"http://hmtotc.com/dev/projects/VRassoc/jamsmagazine.com/images"; $article_edited = str_replace($search, $replace, $article); $article = $article_edited; //Title echo "<center><h2>TITLE</h2></center>"; $oFCKeditor = new FCKeditor('title') ; $oFCKeditor->ToolbarSet = 'title'; $oFCKeditor->Width = '100%' ; $oFCKeditor->Height = '20%' ; $oFCKeditor->BasePath = '' ; $oFCKeditor->Value = $title ; $oFCKeditor->Create() ; //Article echo "<center><h2>ARTICLE</h2></center>"; $oFCKeditor = new FCKeditor('article') ; $oFCKeditor->ToolbarSet = 'article'; $oFCKeditor->Width = '100%' ; $oFCKeditor->Height = '512' ; $oFCKeditor->BasePath = '' ; $oFCKeditor->Value = $article ; $oFCKeditor->Create() ; //Summary echo "<center><h2>SUMMARY</h2></center>"; $oFCKeditor = new FCKeditor('summary') ; $oFCKeditor->ToolbarSet = 'summary'; $oFCKeditor->Width = '100%' ; $oFCKeditor->Height = '50%' ; $oFCKeditor->BasePath = '' ; $oFCKeditor->Value = $summary ; $oFCKeditor->Create() ; ?> http://www.hmtotc.com/dev/projects/VRassoc/jamsmagazine.com/admin/classes/forms/maineditor.php?section=edit_news Thanks Guys Quote Link to comment https://forums.phpfreaks.com/topic/170707-solved-first-button-not-working-but-the-others-do/ Share on other sites More sharing options...
ignace Posted August 17, 2009 Share Posted August 17, 2009 <?php while ($row = mysql_fetch_assoc($result)){ $id = $row['id']; $title = $row['title']; echo $title; echo "<form method=\"post\" action=\"maineditor.php?section=edit_get_news\"><input type=\"hidden\" value=\"$id\" name=\"id\" id=\"id\"><input type=\"submit\" value=\"EDIT ARTICLE\"></form>"; } ?> You can't do that. This will echo: <form method="post" action="maineditor.php?section=edit_get_news"><input type="hidden" value="1" name="id" id="id"><input type="submit" value="EDIT ARTICLE"></form> <form method="post" action="maineditor.php?section=edit_get_news"><input type="hidden" value="2" name="id" id="id"><input type="submit" value="EDIT ARTICLE"></form> <form method="post" action="maineditor.php?section=edit_get_news"><input type="hidden" value="3" name="id" id="id"><input type="submit" value="EDIT ARTICLE"></form> both name and id need to contain a unique value. $results = mysql_query($query) or (mysql_error()); probably needs to be: $results = mysql_query($query) or die(mysql_error()); otherwise if the query fails mysql_error() is called but the script continues processing. Whereby $resultsarray = mysql_fetch_assoc($results) Will throw an E_WARNING: Invalid result resource provided to mysql_fetch_assoc() Quote Link to comment https://forums.phpfreaks.com/topic/170707-solved-first-button-not-working-but-the-others-do/#findComment-900347 Share on other sites More sharing options...
TGWSE_GY Posted August 17, 2009 Author Share Posted August 17, 2009 OK I fixed those problems and the first button is still not working. Quote Link to comment https://forums.phpfreaks.com/topic/170707-solved-first-button-not-working-but-the-others-do/#findComment-900396 Share on other sites More sharing options...
TGWSE_GY Posted August 17, 2009 Author Share Posted August 17, 2009 Ok I fixed it, the issue was I was creating a form within a form and it was somehow messing with the propagation of the first button in the form for selecting the first article. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/170707-solved-first-button-not-working-but-the-others-do/#findComment-900403 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.