Jump to content

help with post chnage


runnerjp

Recommended Posts

Below is a script to edit a forum post but the issue is it edits all the forums posts to the same message e.g

 

b4

 

post1 = hey

post2= how

post3= are

post4= you

 

Now i select post 1 to be changed to 123

 

it should look like this:

 

post1 = 123

post2= how

post3= are

post4= you

 

but looks like this

 

post1 = 123

post2= 123

post3= 123

post4= 123

 

 

<?php 
     
if (isset($_POST['edit'])) { 
$message =  mysql_real_escape_string($_POST['message']); 
       $query = "UPDATE forumtutorial_posts SET  post = '$message' WHERE postid=".$getreplies3['postid']." ";           
         mysql_query($query) or die('Error, query failed'); 
}
else
{ 
echo $getreplies3['postid']      ;
$threadid =  $CONT_ID;     
?> 

<script src="../../css/SpryCollapsiblePanel.js" type="text/javascript"></script> 
      <link href="http://www.runningprofiles.com/css/SpryCollapsiblePanel.css" rel="stylesheet" type="text/css" /> 
      <div id="CollapsiblePanel<?PHP 
       // I had to add $CONT_ID that is set in the script that includes this. and ive done it again for the "tabindex" just to ensure it works!
      echo $CONT_ID; ?>" class="CollapsiblePanel"> 
  <div class="CollapsiblePanelTab" tabindex="<?PHP echo $CONT_ID; ?>"> Edit</div> 
  <div class="CollapsiblePanelContent"> 
<form name='input' action='<?php echo $filename ;?>' method='post'> 
      <div align="center"> 
      <label> 
      <textarea class='inputforum' name="message" id="message" cols="500" rows="5"><? echo $message; ?></textarea> 
      </label> 
            <input type="checkbox" name="deletepost" value="deletepost" /> 
     delete post <br/> 
      <br/> 
       
       
        <input type='submit' name='edit' class="submit-btn"  value='' /> 
  </div> 
</form>      <? 
} 
?></div> 
</div> 


<script type="text/javascript"> 
<!-- 
<?PHP
//Ive added the variable $CONT_ID here aswell. THIS IS REQUIRED FOR THE
//JS to work!
?>
var CollapsiblePanel<?PHP echo $CONT_ID; ?> = new Spry.Widget.CollapsiblePanel("CollapsiblePanel<?PHP echo $CONT_ID; ?>", {contentIsOpen:false}); 
//--> 
      </script>

Link to comment
Share on other sites

It's probably your MySQL query. You don't have periods before and after $message, so it may just be reading to that point and skipping over your WHERE statement.

 

If that doesn't change things, try SELECT with that same query, and see if it returns ALL the rows, or just the row you want.

 

Something along the lines of

"SELECT * WHERE postid=".$getreplies3['postid'];

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.