| gravy |
| Subject: "Awesome"
Date: Mar 08 2007 at 5:27 pm
|
|
|

|
I ca't wait to digg into this code work ow that I have read the tutorial! Great job!
|
| curious |
| Subject: "reverse order; queuing posts"
Date: Sep 06 2007 at 8:25 am
|
|
|
|
|
I will be re-reading more carefully to see if you discuss this, but am interested to know whether the posts can be shown in reverse order (latest post first) and whether the posts can be held in queue and be made live only after the moderator has approved them.
|
| curious |
| Subject: "Thanks"
Date: Sep 06 2007 at 8:27 am
|
|
|
|
|
Many thanks for the tutorial, by the way. I really appreciate it.
|
| bs0d |
| Subject: "Sure Thing"
Date: Sep 10 2007 at 12:41 pm
|
|
|

|
You can change the order of the posts easy enough. Just change from ASC to DESC in the end of the query that grab's the posts (on page 2 of this article).
You can also hold them in "queue" simple enough. Add a column to the table, call it "verify" - you can set it up to be enum ('yes', 'no') with default as no. Then, when you query, query all where verify = yes.
You can make moderators able to see all posts (yes or no), just execute a different query if they're logged in and are moderator. Add a link in the corner of unverified posts that only moderators can see to verify the posts. That link would be to a script that updates the verify column for the post from no to yes.
|
| chinako |
| Subject: "MySQL"
Date: Sep 26 2007 at 10:18 pm
|
|
|
|
|
I love this! As a brand newbie to PHP I find this code and its breakdown to be very helpful.
My question lays within the use of MySQL to get this code functioning properly. As my host does support PHP I asked them about MySQL and they told me that I would need a MySQL database for it, as they don't have one. Is the one we are building with this code all I need, or do I need a "database" that is its own code?
Thank you for taking the time to answer my question! Again, I'm brand new to PHP and MySQL, so I apologize for this if it seems simple.
|
| bs0d |
| Subject: "Database Required"
Date: Sep 27 2007 at 7:27 am
|
|
|

|
Yes, you need a database. This article talks about creating a table IN the database, so they would need to install mySQL. Actually, it's very rare for a hosting company to have PHP and not MySQL or any other database available.
|
| chinako |
| Subject: "Code Goes Where"
Date: Sep 27 2007 at 9:09 am
|
|
|
|
|
Thank you! I'll look into the database issue.
Another question I have is simply where do I put this code? Does it need to go within the HTML pages that require comments? Or is there a link I can add to every blog entry that would point to the comment PHP code as its own page, thus giving me comments for each blog?
Also, how do I tell the code which comments go to which entry? Is there a space for me to program dates of entries so that the comments only show up for the entry they are about?
Again, sorry for so many questions. But thank you very much for your help!
|
| bs0d |
| Subject: "Check the Forums or Search"
Date: Sep 27 2007 at 9:54 am
|
|
|

|
You can check the fourms, or use the search feature in the top-right corner of the site.
Here is a topic that answers your question: PHP Comments Script Question
|
| chinako |
| Subject: "Thanks Again!"
Date: Sep 28 2007 at 10:38 am
|
|
|
|
|
Thank you SO much! You are a wonderful help and I really appreciate that you took the time to type all this out as well as answer questions.
Have a GREAT day!
|
| PyroCandy |
| Subject: "Getting Errors"
Date: Mar 07 2008 at 8:29 pm
|
|
|
|
|
I could use some help once again . . .
I have the db created in mySQL and put the script code into my page . . .but when I try to load the page it give me a PHP error message right on the page.
pyrocandy.890m.com/comments.php
plz and ty for all your help
hope to hear from you soon
|
| jyogit |
| Subject: "help needed"
Date: Mar 19 2008 at 4:02 am
|
|
|
|
|
well ive created the dbase and copied and pasted the code.
on the final full code u have ommited the first line of the connect once code....
i cant get this to work at all.
am i missing something?
|
| cefx |
| Subject: "customize"
Date: Jun 19 2008 at 1:53 pm
|
|
|
|
|
is there anyway i can customize the out come of the comment... i.e. wat it looks like?
|
| bs0d |
| Subject: "Yes"
Date: Jun 19 2008 at 7:35 pm
|
|
|

|
Yes, the outcome of the comment is up to your creativity with HTML/CSS.
|
| serdas |
| Subject: "how would see if they're logged in..."
Date: Feb 04 2009 at 8:00 am
|
|
|
|
|
"If you have a users system, then it will be very easy for you to see if they're logged in and display their member name in the username field"
how would i do that?
|
| craig |
| Subject: "Getting Access Denied"
Date: Jun 23 2009 at 8:32 am
|
|
|
|
|
I've pasted your script into a file called Comments.php but when I access that page I get the error messages below:
<
Warning: mysql_query() [function.mysql-query]: Access denied for user: 'craig@localhost' (Using password: NO) in /home/craig/www/www/Comments.php on line 12
Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/craig/www/www/Comments.php on line 12
Access denied for user: 'craig@localhost' (Using password: NO)
Can you point me to where I've gone wrong?
Thanks!
|
| bs0d |
| Subject: "db_connect"
Date: Jun 23 2009 at 4:06 pm
|
|
|

|
Sounds like you've won 1/2 the battle. Remember to connect to the database first: PHP - Connect to Database
|
| deflipp |
| Subject: "Comment isn't being reposted?"
Date: Apr 21 2010 at 2:24 pm
|
|
|
|
|
I have been looking for this type of tutorial FOREVER! It was SOOOO helpful!
Anyway, I have followed your script, but when i submit the comments, they don't want to post... The page refreshes and remains the same. When I go to phpMyAdmin, it says the table is empty. What could I have done wrong?
Here is the code for my test page:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; carset=utf-8" />
<meta name="description" content="A research collaboration on the country Russia and its totalitarian roots for a jYork group project stemming from George Orwell's 1984." />
<meta name="keywords" content="russia, totalitarian, research, george orwell, 1984, regime, soviet union, USSR, project" />
<title>The Russia Project- A YorkBrit 1984 Research Collaboration</title>
<link rel="stylesheet" type="text/css" href="trp.css" />
</head>
<body>
<img class="bgimg" src="ussr and russia flag.png" alt="" />
<div class="wrap">
<div class="header">
<img class="headerimg" src="trpheader.png" alt="The Russia Project: A YorkBrit 1984 Research Collaboration" />
</div>
<div class="menubar">
<table class="menubar" cellpadding="0px" cellspacing="0px">
<tr>
<td id="leftendcap"> </td>
<td>
<a href="index.html" id="home"><span>Home</span></a>
</td>
<td>
<a href="ussr.html" id="ussr"><span>U.S.S.R.</span></a>
</td>
<td>
<a href="russia.html" id="russia"><span>Russia</span></a>
</td>
<td>
<a href="workscited.html" id="workscited"><span>Works Cited</span></a>
</td>
<td id="rightendcap"> </td>
</tr>
</table>
</div>
<center>
<div class="content">
<h1 class="page-title">COMMENT TEST PAGE</h1>
<br />
<hr id="article_comment_break" noshade />
<?php
require_once($_SERVER['DOCUMENT_ROOT']. '/database_connect.php');
//querying comments for this article
$inf = "SELECT * FROM `comments` WHERE page = '".stripslashes($_SERVER['REQUEST_URI'])."' ORDER BY time";
$info = mysql_query($inf) or die ( mysql_error() );
if( mysql_num_rows( $info ) != 0 ) {
echo '<h3 class="comments">Comments:</h3>';
echo '<table class="comments">';
while ( $info2 = mysql_fetch_object( $info ) ) {
echo '<tr>';
echo '<td>'.htmlspecialchars(stripslashes($info2->subject)).'" by: <a href="'.$info2->contact.'">'.htmlspecialchars(stripslashes($info2->username)).'</a></td><td><div> @ '.date('h:is a', $info2->time).' on '.$info21->date.'</div></td>';
echo '</tr><tr>';
echo '<td colspan="2"> '.htmlspecialchars(stripslashes(n12br($info2->comment))).' </td>';
echo '</tr>';
} // end while
echo '</table>';
echo '<hr noshade width="500px" align="center" />';
}
else echo 'No comments for this page. Feel free to be the first. <br />';
if (isset($_POST['submit'])) {
if(!addslashes($_POST['username'])) {
die('<u>ERROR:</u> You must enter an alias to comment.');
}
if(!addslashes($_POST['contact'])) {
die('<u>ERROR:</u> Please enter an email or URL to comment.');
}
if(!addslashes($_POST['subject'])) {
die('<u>ERROR:</u> Please give your comment a subject.');
}
if(!addslashes($_POST['comment'])) {
die('You <u>must</u> enter a comment in order to comment (DUH!).');
}
// this is for a valid contact
if(substr($_POST['contact'],0,7) != 'mailto:' && !strstr($_POST['contact'],'//')) {
$_POST['contact'] = "mailto:".$_POST['contact']."";
}
else {
$_POST['contact'] = "http://".$_POST['contact']."";
}
// end valid contact
//add comment
$q = "INSERT INTO `comments` VALUES ('".$_GET['id']."', '".$_POST['page']."', '".$_POST['date']."', '".$_POST['time']."', '".addslashes(htmlspecialchars($_POST['username']))."', '".$_SERVER['REMOTE_ADDR']."', '".addslashes(htmlspecialcharacters($_POST['contact']))."', '".addslashes(htmlspecialchars($_POST['subject']))."', '".addslashes(nl2br(htmlspecialchars($_POST['comment'])))."')";
$q2 = mysql_query($q);
if(!$q2) die(mysql_error());
//refresh page so they can see new comment
header('Location: http://' . $_SERVER['HTTP_HOST'] . $_POST['page'] . "#comments");
}
else { //display form
?>
<form name="comments" action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<input type="hidden" name="page" value="<?php echo($_SERVER['REQUEST_URI']); ?>">
<input type="hidden" name="date" value="<?php echo(date()); ?>">
<input type="hidden" name="date" value="<?php echo (time()); ?>">
<div class="form_fields" >
<label>Alias:</label><input type="text" name="username" size="30"><br />
<label>Subject:</label><input type="text" name="subject" size="30"><br />
<label>Email or URL:</label><input type="text" name="contact" size="30"><br />
<label>Message:</label><textarea name="comment" rows="5" cols="24"></textarea><br />
<input type="submit" value="Post Comment" />
</div>
<?php
} //end else
?>
</div>
</div>
</center>
<div class="footer">
<p class="footer"> Design ©2010 Scriptech Designs • Content ©2010 YorkBrit English 11-4</p>
</div>
</div>
</body>
</html>
I also want to know if you know of a good CAPTCHA resource, as I think that type of addition would be a good idea.... but I don't know....
|
| bs0d |
| Subject: "Hmmm"
Date: Apr 22 2010 at 9:43 am
|
|
|

|
I didn't notice anything immediately in your code. It looks like you have some error handling if the query fails... are you using the right table name in the query to match what is in the database? If phpMyAdmin shows nothing, then it's not inserting the comment in the DB, which would explain why your page shows nothing.
There is a CAPTCHA code on our site here.
|