Jump to content


Help with code


3 replies to this topic

#1 ProgrammerXtreme

    Member

  • Members
  • PipPip
  • 53 posts

Posted 11 December 2004 - 11: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

#2 ProgrammerXtreme

    Member

  • Members
  • PipPip
  • 53 posts

Posted 11 December 2004 - 11: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

#3 Dia

    DevMaster Staff

  • Administrators
  • 1121 posts

Posted 12 December 2004 - 12:11 AM

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` ");

#4 ProgrammerXtreme

    Member

  • Members
  • PipPip
  • 53 posts

Posted 12 December 2004 - 02:40 AM

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)){ 






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users