WHILE I tear my hair off!!
Posted: Tue Jan 07, 2003 9:41 pm
I'm trying to make a message-board, and when listing replies below a message I'm trying to list them tab'ed in under the message it's a reply to.
I'm using this code:
This works ok, except if I'm looking at a post which is a reply to a reply to a reply to a reply
the tab's just pushes the replies faaar to the right on my screen, even the first one, because the first one has a lot of parents even if they are not shown...so I tried this in stead:
Because I figured then it would stop counting parents at the current message, but here the trouble begins:
When I try to run this code I get:
Header of current message.
Body of current message.
Warning: Unable to jump to row 0 on MySQL result index 4 in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
This goes on forever....
Any hints anyone?
I'm probably just tired and stupid, but I don't get it, anyone?
Thanx.
Rincewind_the_Wizzard
I'm using this code:
Code: Select all
<html>
<head>
<title>Message</title>
</head>
<body>
<?php
include_once("php/pass.php");
$link = mysql_pconnect( $host, $user, $pass );
if( ! $link )
die( "Couldn't connect to database-server!" );
mysql_select_db( $db, $link)
or die("Couldn't connect to $db:".mysql_error() );
$id = $_GETї'id'];
$msg = mysql_query( "SELECT * FROM msg WHERE id = $id");
$head = mysql_result($msg, 0, head);
$body = mysql_result($msg, 0, body);
$parent = mysql_result($msg, 0, parent);
$grp = mysql_result($msg, 0, grp);
$id2 = $id;
function listchild($id)
{
global $id2;
$msg = mysql_query( "SELECT head, child, id, parent FROM msg WHERE id = $id" );
$child = mysql_result($msg, 0, child);
$head = mysql_result($msg, 0, head);
$parent = mysql_result($msg, 0, parent);
$antparent = 0;
while( $parent != 0 )
{
$parent = mysql_query( "SELECT parent FROM msg WHERE id = $parent" );
$parent = mysql_result($parent, 0, parent);
++$antparent;
}
while( $antparent != 0 )
{
print"<img src='blank.gif' width='20' height='20'>";
--$antparent;
}
if( $id != $id2 )
{
echo"<a href=msg.php?id=$id>$head</a> --- $child<BR>";
}
if( $child > 0)
{
$msg = mysql_query( "SELECT head, child, id FROM msg WHERE parent = $id" );
$childant = mysql_num_rows($msg);
for ($nr = 0; $childant > $nr; ++$nr)
{
$idsend = mysql_result( $msg, $nr, id );
listchild($idsend);
}
}
}
echo"$head<BR>";
echo"$body<BR>";
echo"<a href=svar.php?parent=$id&?grp=$grp> Svar på dette innlegget </a><BR>";
listchild($id);
mysql_close($link);
?>
</body>
</html>the tab's just pushes the replies faaar to the right on my screen, even the first one, because the first one has a lot of parents even if they are not shown...so I tried this in stead:
Code: Select all
<html>
<head>
<title>Message</title>
</head>
<body>
<?php
include_once("php/pass.php");
$link = mysql_pconnect( $host, $user, $pass );
if( ! $link )
die( "Couldn't connect to database-server!" );
mysql_select_db( $db, $link)
or die("Couldn't connect to $db:".mysql_error() );
$id = $_GETї'id'];
$msg = mysql_query( "SELECT * FROM msg WHERE id = $id");
$head = mysql_result($msg, 0, head);
$body = mysql_result($msg, 0, body);
$parent = mysql_result($msg, 0, parent);
$grp = mysql_result($msg, 0, grp);
$id2 = $id;
function listchild($id)
{
global $id2;
$msg = mysql_query( "SELECT head, child, id, parent FROM msg WHERE id = $id" );
$child = mysql_result($msg, 0, child);
$head = mysql_result($msg, 0, head);
$parent = mysql_result($msg, 0, parent);
$antparent = 0;
while( $parent != $id )
{
$parent = mysql_query( "SELECT parent FROM msg WHERE id = $parent" );
$parent = mysql_result($parent, 0, parent);
++$antparent;
}
while( $antparent != 0 )
{
print"<img src='blank.gif' width='20' height='20'>";
--$antparent;
}
if( $id != $id2 )
{
echo"<a href=msg.php?id=$id>$head</a> --- $child<BR>";
}
if( $child > 0)
{
$msg = mysql_query( "SELECT head, child, id FROM msg WHERE parent = $id" );
$childant = mysql_num_rows($msg);
for ($nr = 0; $childant > $nr; ++$nr)
{
$idsend = mysql_result( $msg, $nr, id );
listchild($idsend);
}
}
}
echo"$head<BR>";
echo"$body<BR>";
echo"<a href=svar.php?parent=$id&?grp=$grp> Svar på dette innlegget </a><BR>";
listchild($id);
mysql_close($link);
?>
</body>
</html>When I try to run this code I get:
Header of current message.
Body of current message.
Warning: Unable to jump to row 0 on MySQL result index 4 in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
Warning: mysql_result(): supplied argument is not a valid MySQL result resource in /www/htdocs/msg-board/msg.php on line 32
This goes on forever....
Any hints anyone?
I'm probably just tired and stupid, but I don't get it, anyone?
Thanx.
Rincewind_the_Wizzard