Help with code

3e884a0fb65ac56e7f79b10bb0684fd1
0
ProgrammerXtreme 101 Dec 11, 2004 at 23:05

hi. I am making a forum, and I want to display the time the last post was made, and I am stuck at making the post tell which forum it is in. here is the source:

<?
session_start();
include('header.php');
include('connect.php');



if ($_POST[cr_post]){
$youass = mysql_query("SELECT * FROM * `Threads` WHERE `Forum` = `$id` ");
while ($id = mysql_fetch_row($youass)){ 

mysql_query("INSERT INTO `Posts` ( `Name` , `id` , `Content` , `Thread` , `poster` , `date` , `time` ) VALUES ('$_POST[ps_sub]', '', '$_POST[ps_mes]', '$ps_forum', '$_POST[ps_user]', CURDATE(), CURTIME() )");
mysql_query("UPDATE `Forums` SET `Last Post` = CURTIME() WHERE `id` = `$id` ");
?>
<META HTTP-EQUIV='refresh' content='1;URL=threadview.php?thread=<?=$ps_forum?>'>
<?
}
}

include('doc.html');
?>

The link to it is: http://programmersunited.com/new_forum
:) Please help. If you need more details, post

3 Replies

Please log in or register to post a reply.

3e884a0fb65ac56e7f79b10bb0684fd1
0
ProgrammerXtreme 101 Dec 11, 2004 at 23:09

oh and the error is:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/program/public_html/new_forum/postdo.php on line 10

Fdbdc4176840d77fe6a8deca457595ab
0
dk 158 Dec 12, 2004 at 00:11

Assuming line 10 is: while ($id = mysql_fetch_row($youass)){
it probably means your SQL query is incorrect. Did you mean:

mysql_query(“SELECT * FROM `Threads` WHERE `Forum` = `$id` “);

3e884a0fb65ac56e7f79b10bb0684fd1
0
ProgrammerXtreme 101 Dec 12, 2004 at 02:40

new code:

<?
session_start();
include('header.php');
include('connect.php');



if ($_POST[cr_post]){
 $youass = mysql_query("SELECT * FROM `Threads` WHERE `Forum` = '$id' ");
while ($id = mysql_fetch_row($youass)){ 

mysql_query("INSERT INTO `Posts` ( `Name` , `id` , `Content` , `Thread` , `poster` , `date` , `time` ) VALUES ('$_POST[ps_sub]', '', '$_POST[ps_mes]', '$ps_forum', '$_POST[ps_user]', CURDATE(), CURTIME() )");
mysql_query("UPDATE `Forums` SET `Last Post` = CURTIME() WHERE `id` = `$id` ");
?>
<META HTTP-EQUIV='refresh' content='1;URL=threadview.php?thread=<?=$ps_forum?>'>
<?
}
}

include('doc.html');
?>

I am having trouble with:

mysql_query("UPDATE `Forums` SET `Last Post` = CURTIME() WHERE `id` = `$id` ");

and

$youass = mysql_query("SELECT * FROM `Threads` WHERE `Forum` = '$id' ");
while ($id = mysql_fetch_row($youass)){