PDA

View Full Version : Help with code


ProgrammerXtreme
12-11-2004, 04:05 PM
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

ProgrammerXtreme
12-11-2004, 04:09 PM
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

Dia Kharrat
12-11-2004, 05:11 PM
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` ");

ProgrammerXtreme
12-11-2004, 07:40 PM
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)){