I actually
asked someone
to help, and he
fixed most of
the problem.
I'm not quite
sure what he
changed on
comment.php,
but on the
news.php, i've
noticed:
Code:
$dbhost='local
host';
$dbusername='
';
$dbuserpass='
';
$dbname='';
//connecting
to mysql
mysql_connect
($dbhost,
$dbusername,
$dbuserpass);
mysql_select_db
($dbname) or
die('Cannot
select
database.');
$q_articles =
mysql_query(&q
uot;SELECT *
FROM `articles`
ORDER BY `id`
DESC"

;
if(!$q_articles
)
die(mysql_error
());
while($show =
mysql_fetch_obj
ect($q_articles
)) {
echo("&q
uot;.$show->
title."
<hr>Poste
d by:
".$show-&
gt;username.&q
uot; @
".date('
h:i:s a',
$show->time)
." on
".$show-&
gt;date."
<BR>
".$show-&
gt;article.&qu
ot;<hr>
"

;
//now query
comments for
this article
$q2 =
mysql_query(&q
uot;SELECT *
FROM `comments`
WHERE
`article_id` =
'".$show
->id."
'"<im
g
src=http://www.
allsyntax.com/f
orums/images/sm
ilies/wink.gif
border=0>;
$howmany =
mysql_numrows($
q2);
if($howmany ==
0) {
echo('<a
href="com
ment.php?id='.
$show->id.'
">comm
ents:(0)</a&
gt;<hr>'
);
}
if($howmany !=
0) {
echo('<a
href="com
ment.php?id='.
$show->id.'
">comm
ents:
('.$howmany.'
)
</a><B
R><hr>
');
}//end else
} //end while
if ($hehe == 1)
{
$hehe = 0;
header('Locati
on: http://' .
$_SERVER['HTTP
_HOST'] .
$_POST['page'
] .
"#comment
s"

;
}
ob_start();
//connect to
your database
$dbhost='local
host';
$dbusername='
';
$dbuserpass='
';
$dbname='';
mysql_connect
($dbhost,
$dbusername,
$dbuserpass);
mysql_select_db
($dbname) or
die('Cannot
select database
because of
mysql_error()'
);
//query
comments for
this page of
this article
$inf =
"SELECT *
FROM `comments`
WHERE page =
'".strip
slashes($_SERVE
R['REQUEST_URI
'])."'
ORDER BY time
ASC";
$info =
mysql_query($in
f);
if(!$info)
die(mysql_error
());
$info_rows =
mysql_num_rows(
$info);
if($info_rows
> 0) {
echo
'<h5>Com
ments:</h5&g
t;';
echo
'<table
width="95
%">';
while($info2 =
mysql_fetch_obj
ect($info)) {
echo
'<tr>';
echo
'<td>&q
uot;'.stripsla
shes($info2->
;subject).'&q
uot; by: <a
href="'.
$info2->cont
act.'"&g
t;'.stripslash
es($info2->u
sername).'<
/a></td&g
t;
<td><d
iv
align="ri
ght">
@
'.date('h:i:s
a',
$info2->time
).' on
'.$info2->d
ate.'</div&
gt;</td>
';
echo
'</tr>&l
t;tr>';
echo '<td
colspan="
2">
'.stripslashes
($info2->com
ment).'
</td>';
echo
'</tr>'
;
}//end while
echo
'</table>
;';
echo '<hr
width="95
%"
noshade>';
} else echo
'No comments
for this page.
Feel free to be
the first
<br>';
if(isset($_POST
['submit']))
{
if(!addslashes(
$_POST['userna
me']))
die('<u>
ERROR:</u>
; you must
enter a
username to add
a comment.');
if(!addslashes(
$_POST['contac
t']))
die('<u>
ERROR:</u>
; enter contact
method in
contact
field.');
if(!addslashes(
$_POST['subjec
t']))
die('<u>
ERROR:</u>
; enter a
subject to your
comment.');
if(!addslashes(
$_POST['commen
t']))
die('<u>
ERROR:</u>
; cannot add
comment if you
do not enter
one!?');
//this is for a
valid contact
if(substr($_POS
T['contact'],
0,7) !=
'mailto:'
&&
!strstr($_POST[
'contact'],'
//')) {
if(strstr($_POS
T['contact'],
'@'))
$_POST['contac
t'] =
"mailto:
".$_POST[
'contact'].&q
uot;";
else
$_POST['contac
t'] =
"http://
".$_POST[
'contact'].&q
uot;";
} //end
valid contact
//try to
prevent
multiple posts
and flooding...
$c =
"SELECT *
from `comments`
WHERE ip =
'".$_SER
VER['REMOTE_AD
DR']."'
";
$c2 =
mysql_query($c)
;
while($c3
=
mysql_fetch_obj
ect($c2)) {
$difference =
time() -
$c3->time;
if($difference
< 300)
die('<u>
ALERT:</u>
;
'.$c3->user
name.', You
have already
commented
earlier; if you
have a
question, try
the
forums!<BR&g
t;');
} //end
while
//add comment
$q
="INSERT
INTO `comments`
(article_id,
page, date,
time, username,
ip, contact,
subject,
comment) VALUES
('".$HTT
P_GET_VARS['id
']."',
'".$_POS
T['page'].&q
uot;',
'".$_POS
T['date'].&q
uot;',
'".$_POS
T['time'].&q
uot;',
'".addsl
ashes(htmlspeci
alchars($_POST[
'username']))
."',
'".$_SER
VER['REMOTE_AD
DR']."'
,
'".addsl
ashes(htmlspeci
alchars($_POST[
'contact'])).
"',
'".addsl
ashes(htmlspeci
alchars($_POST[
'subject'])).
"',
'".addsl
ashes(htmlspeci
alchars(nl2br($
_POST['comment
'])))."
')";
$q2 =
mysql_query($q)
;
if(!$q2)
die(mysql_error
());
//refresh page
so they can see
new comment
$haha = 1;
} else {
//display form
?>
<form
name="com
ments"
action="&
lt;?
$_SERVER['PHP_
SELF'];
?>"
method="p
ost">
<input
type="hid
den"
name="pag
e"
value="&l
t;?
echo($_SERVER[
'REQUEST_URI']
);
?>">
;
<input
type="hid
den"
name="dat
e"
value="&l
t;?
echo(date(&quo
t;F j,
Y."

);
?>">
;
<input
type="hid
den"
name="tim
e"
value="&l
t;?
echo(time());
?>">
;
<table
width="90
%"
border="0
"
cellspacing=&q
uot;0"
cellpadding=&q
uot;0">
;
<tr>
<td><d
iv
align="ri
ght">U
sername:
</div><
;/td>
<td><i
nput
name="use
rname"
type="tex
t"
size="30
"
value="&
quot;></t
d>
</tr>
<tr>
<td><d
iv
align="ri
ght">C
ontact:
</div><
;/td>
<td><i
nput
type="tex
t"
name="con
tact"
size="30
"
value="&
quot;>
<i>(email
or
url)</i>&
lt;/td>
</tr>
<td><d
iv
align="ri
ght">S
ubject:
</div><
;/td>
<td><i
nput
type="tex
t"
name="sub
ject"
size="30
"
value="&
quot;></t
d>
</tr>
<tr>
<td><d
iv
align="ri
ght">C
omment:
</div><
;/td>
<td><t
extarea
name="com
ment"
cols="45
"
rows="5&
quot;
wrap="VIR
TUAL">
</textarea&g
t;</td>
</tr>
<tr>
<td></
td>
<td
colspan="
2"><
;input
type="res
et"
value="Re
set
Fields"&g
t;
<input
type="sub
mit"
name="sub
mit"
value="Ad
d
Comment"&
gt;</td>
</tr>
</table>
</form>
<?
} // end else
?>
Since the
article_id
wasn't being
recorded
correctly =p.
But now I'm
having issues
with refreshing
after posting
when there is
no comment =/.
He changed or
replace the
refreshing code
cause when the
ppl click on
the comment
link and post a
new comment, it
wouldn't
refresh.