under each topic in my forums i have a reply iframe:
<?
//bla bla bla
$topicid = $_GET['topicid'];
if(empty($id)){
echo 'You have to log in to reply';
}else{
?>
<center>
<iframe src="forumreply.php?topicid=<? echo $topicid; ?>&userid=<? echo $id; ?>" width="400" height="200">
ERROR(NOT REPLY FAIL)
</iframe>
</center>
<center>
<?
}
?>
The forumreply.php
<?
$id = $_GET['id'];
$topicid = $_GET['topicid'];
?>
<form method="post" action="savereply.php?id=<? echo $id; ?>&topicid=<? echo $topicid; ?>">
<textarea rows="10" cols="20" name="thereply"></textarea>
<br /><input type="submit" value="Submit"> | <input type="reset" value="ERASE!"></form>
The savereply.php
<center><img src="save.gif"><br />
Saving reply...
</center>
<?php
$id = $_GET['id'];
$topicid = $_GET['topicid'];
include("config.php");
$query = "SELECT id FROM users where username = '".$id."'";
$result = mysql_query($query);
list($userid) = mysql_fetch_row($result);
$content = $_POST['thereply'];
$safecontent = htmlentities($content);
$brline = nl2br($safecontent);
$content = $brline;
$query = "INSERT INTO posts (user_id,topic_id,content)
VALUES('$userid','$topicid','$content')";
mysql_query($query) or die(mysql_error());
$query = "UPDATE topics SET last_user_id = '".$id."' WHERE topic_id = '" .$topicid. "'";
mysql_query($query);
$query = "SELECT post_id FROM posts ORDER BY `post_id` DESC LIMIT 1";
$result = mysql_query($query);
list($postid) = mysql_fetch_row($result);
echo '
<meta HTTP-EQUIV="REFRESH" content="1; url=viewpost.php?postid='.$postid.'">';
?>
And then it shows you the post:
<?php
$postid = $_GET['postid'];
include("config.php");
$query = "SELECT content,userid FROM posts WHERE post_id = '".$postid."'";
$result = mysql_query($query);
while(list($content,$userid) = mysql_fetch_row($result)){
$query = "SELECT username,signature,avatar FROM users WHERE id = '".$userid."'";
$result = mysql_query($query);
list($username,$sig,$avvy) = mysql_fetch_row($result);
echo '<table width="400"><tr><td colspan="3">'.$username.'</td></tr><tr>
<td><img src="'.$avvy.'" align="top"></td><td>'.$content.'<hr />'.$sig.'</td></tr></table>';
}
?>
This is where it goes wrong
It shows me this error:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /host/z/c/o/zcollvee/viewpost.php on line 6
What is wrong?