problem with updating comments in a blog

Posted on 2006-10-23
Last Modified: 2010-04-25
i am folowing this tutorial, and i am stuck with updating the comments.

i do not use the extension.
so i have built 2 pages: list_comm.php and edit_com.php.
i created a list from a recordset and added an update button wich goes to the edit page with the URL parameter of the id_com.

then i built the update form, which can edit the text and say if the comment will be sown or not. therefore i used a checkbox.

well it works but only parcially. i select a comment and click the update button. and indeed the edit page loads with the selected comment. then i check or uncheck the valid checkbox, and click "update".

then the list of comments load and the change indeed is shown there.

but when i go to the article that this comment is attached to, it is not shown. there fore there has been an update but it is shows only in the admin area and not in the front-end blog.

what am i doing wrong?

best regards

Question by:derrida
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4

Author Comment

ID: 17787213
i now see that i have 2 other problems that i hope you can help me with:
regarding this section of that tutorial:

first problem: the date for the erticle itself is displaying fine, but when someone post a comment the date dose not show, even though the right dynamic element is in the form (rsComments.date_com). in the database both the article date and the comment date are set with the same parameters.

second problem: even though the tutorial say that a comment will be shown only after the manager validate it, when i insert a comment it appears immediatly.

i really appriciate any help.

ps. i hope jason will read it and continue with his great help.

LVL 70

Expert Comment

by:Jason C. Levine
ID: 17789919

Since you are not using Interakt's extensions, it's easier for us if you post the PHP code from your pages (not the HTML, unless we ask for it later).

Author Comment

ID: 17790326
thanks for answering:

this is the recordset for updating:
$colname_rsCommentUpdate = "-1";
if (isset($_GET['id_com'])) {
  $colname_rsCommentUpdate = (get_magic_quotes_gpc()) ? $_GET['id_com'] : addslashes($_GET['id_com']);
mysql_select_db($database_connBlog, $connBlog);
$query_rsCommentUpdate = sprintf("SELECT * FROM blg_comment_com WHERE id_com = %s", GetSQLValueString($colname_rsCommentUpdate, "int"));
$rsCommentUpdate = mysql_query($query_rsCommentUpdate, $connBlog) or die(mysql_error());
$row_rsCommentUpdate = mysql_fetch_assoc($rsCommentUpdate);
$totalRows_rsCommentUpdate = mysql_num_rows($rsCommentUpdate);

and this is the update form:

 <form method="post" name="form1" action="<?php echo $editFormAction; ?>">
          <table align="center">
            <tr valign="baseline">
              <td nowrap align="right" valign="top">Comment:</td>
              <td><textarea name="text_com" cols="50" rows="5"><?php echo $row_rsCommentUpdate['text_com']; ?></textarea>
            <tr valign="baseline">
              <td nowrap align="right">Valid:</td>
              <td><input type="checkbox" name="valid_com" value=""  <?php if (!(strcmp($row_rsCommentUpdate['valid_com'],0))) {echo "@@checked@@";} ?>></td>
            <tr valign="baseline">
              <td nowrap align="right">&nbsp;</td>
              <td><input type="submit" value="Update "></td>
          <input type="hidden" name="MM_update" value="form1">
          <input type="hidden" name="id_com" value="<?php echo $row_rsCommentUpdate['id_com']; ?>">

this is the recordset for the list page, that shows the list of comments:

mysql_select_db($database_connBlog, $connBlog);
$query_rsComments = "SELECT * FROM blg_comment_com ORDER BY date_com DESC";
$query_limit_rsComments = sprintf("%s LIMIT %d, %d", $query_rsComments, $startRow_rsComments, $maxRows_rsComments);
$rsComments = mysql_query($query_limit_rsComments, $connBlog) or die(mysql_error());
$row_rsComments = mysql_fetch_assoc($rsComments);

if (isset($_GET['totalRows_rsComments'])) {
  $totalRows_rsComments = $_GET['totalRows_rsComments'];
} else {
  $all_rsComments = mysql_query($query_rsComments);
  $totalRows_rsComments = mysql_num_rows($all_rsComments);
$totalPages_rsComments = ceil($totalRows_rsComments/$maxRows_rsComments)-1;

$queryString_rsComments = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_rsComments") == false && 
        stristr($param, "totalRows_rsComments") == false) {
      array_push($newParams, $param);
  if (count($newParams) != 0) {
    $queryString_rsComments = "&" . htmlentities(implode("&", $newParams));
$queryString_rsComments = sprintf("&totalRows_rsComments=%d%s", $totalRows_rsComments, $queryString_rsComments);

and this is the form for the list:

<?php echo ($startRow_rsComments + 1) ?> to <?php echo min($startRow_rsComments + $maxRows_rsComments, $totalRows_rsComments) ?> of <?php echo $totalRows_rsComments ?>      <br />
      <table cellpadding="3" cellspacing="0" class="topic">
          <tr class="nugheader">
            <td>user number</td>
          <?php do { ?>
              <td><?php echo $row_rsComments['text_com']; ?></td>
              <td><?php echo $row_rsComments['idusr_com']; ?></td>
              <td><?php echo $row_rsComments['date_com']; ?></td>
              <td><?php echo $row_rsComments['valid_com']; ?></td>
              <td><a href="edit_com.php?id_com=<?php echo $row_rsComments['id_com']; ?>"><img src="../images/update.gif" alt="update" width="23" height="23" border="0" /></a></td>
            <?php } while ($row_rsComments = mysql_fetch_assoc($rsComments)); ?>

sorry to post all that code.

i think that the problem is with the recordsets but i`m not sure what i am doing wrong there.
maybe its too simple and i need to use the advanced  recordset and to combine another table?

in any case i really appriciate your help.

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

LVL 70

Expert Comment

by:Jason C. Levine
ID: 17800455

I have not forgotten you.  I've had some RL stuff to take care of.
LVL 70

Accepted Solution

Jason C. Levine earned 250 total points
ID: 17801109

I see your recordset code, what I don't see is the code that updates the comment table after the form is submitted.  Where is the update behavior?

Also, a brief word about the Interakt stuff.  You don't need to have it installed to do most of the tutorial.  The Interakt extensions will automate form building and form validation, but if you know how to build forms, all you need to do is apply the DW Insert or Update Record behaviors to get the same functionality.  The Interakt stuff adds a lot of extra functionality and is quite advanced if you dig into it but the basic Insert and Update functions aren't a heck of lot different than DW.  If  the tutorial asks you to use Interakt's Update function, just make the same form and apply DW's update function.  Same effect, minus the form validation.

Author Comment

ID: 17802099
hi jason

thanks for the answer.
well now i am updating the comment table:) it works.

so now there is the older problem that even though i put the date dynamic element in the comment table in DW , and even though it has the same values as the date field in the database, the date appear for the article but not for the comment.

another issue comes in the next chapter of the blog tutorial.
concerning this section:

i created a user list page and added an update button which take the id_usr.
a problem that arises is: when i click the update button i go to the edit_user page but it does not set the user i have chosen from the list. i thought that when i asked for the id_usr, the edit page will come up with this user info.

then i created a form like the tutorial make (nextensio form, but i`m doing it without the extension).
there are 4 buttons there. icreated each one but have no idea how to make them function correctly.

again, i am very thankfull for your great help.



Author Comment

ID: 17802471
i hope i can ask another question which shows hoe much a begginer i am:)

in myadmin when i build a table i have some choises but in most cods i see they have it either as MyISAM or InnoDB.
how do i know what to chose and what is the difference between them?

best regards

LVL 70

Expert Comment

by:Jason C. Levine
ID: 17804534

We should keep the question to one per thread.  If the comment table is updating, let's close this and repost the next two questions so that other experts have a shot at helping you.

Author Comment

ID: 17804840
ho ok:)

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
dreamweaver cs6 keep getting error 2 msg 16 397
Resume template for HTML/Dreamweaver website 9 533
Remove LF from html text 5 421
Dreamweaver CS6 Audio File Autoplay Always Plays 2 121
Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question