• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

problem with updating comments in a blog

hi
i am folowing this tutorial, and i am stuck with updating the comments.
http://www.adobe.com/devnet/dreamweaver/articles/php_blog5_03.html

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

ron
0
derrida
Asked:
derrida
  • 5
  • 4
1 Solution
 
derridaAuthor Commented:
hi
i now see that i have 2 other problems that i hope you can help me with:
regarding this section of that tutorial: http://www.adobe.com/devnet/dreamweaver/articles/php_blog4_08.html

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.

ron
0
 
Jason C. LevineNo oneCommented:
Ron,

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).
0
 
derridaAuthor Commented:
hi
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>
              </td>
            </tr>
            <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>
            <tr valign="baseline">
              <td nowrap align="right">&nbsp;</td>
              <td><input type="submit" value="Update "></td>
            </tr>
          </table>
          <input type="hidden" name="MM_update" value="form1">
          <input type="hidden" name="id_com" value="<?php echo $row_rsCommentUpdate['id_com']; ?>">
        </form>


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>Comment</td>
            <td>user number</td>
            <td>date</td>
            <td>valid</td>
            <td>&nbsp;</td>
          </tr>
          <?php do { ?>
            <tr>
              <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>
            </tr>
            <?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.

ron
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
Jason C. LevineNo oneCommented:
Ron,

I have not forgotten you.  I've had some RL stuff to take care of.
0
 
Jason C. LevineNo oneCommented:
Okay,

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.
0
 
derridaAuthor Commented:
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:http://www.adobe.com/devnet/dreamweaver/articles/php_blog5_05.html

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.

ron

0
 
derridaAuthor Commented:
hi
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

ron
0
 
Jason C. LevineNo oneCommented:
Ron,

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.
0
 
derridaAuthor Commented:
ho ok:)
sorry
0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now