Solved

problem with updating comments in a blog

Posted on 2006-10-23
9
159 Views
Last Modified: 2010-04-25
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
Comment
Question by:derrida
  • 5
  • 4
9 Comments
 
LVL 1

Author Comment

by:derrida
ID: 17787213
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
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 17789919
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
 
LVL 1

Author Comment

by:derrida
ID: 17790326
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 17800455
Ron,

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

Accepted Solution

by:
Jason C. Levine earned 250 total points
ID: 17801109
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
 
LVL 1

Author Comment

by:derrida
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: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
 
LVL 1

Author Comment

by:derrida
ID: 17802471
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
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 17804534
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
 
LVL 1

Author Comment

by:derrida
ID: 17804840
ho ok:)
sorry
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ColdFusion dropdown multiple select question 3 628
submit button form code 2 429
Dreamweaver CS4 filling forms 2 140
Create recordset using Dreamweaver PHP and MS SQL 2008 4 550
I still run into .cgi files every now and then. In some instances, I actually prefer the simplicity of a .cgi script to other options. Since I use DreamWeaver extensively, what I needed was a way to open .cgi scripts in Dreamweaver. And I wanted to …
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

809 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