Jump to content

[SOLVED] First button not working, but the others do


TGWSE_GY

Recommended Posts

:facewall:

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

Link to comment
Share on other sites

<?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()

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.