PDA

View Full Version : need help with some errors


sytodave88
08-04-2005, 11:18 AM
Fatal error: Using $this when not in object context in /home/vhosts/globolwarfare.e2uhosting.com/testphp/php/main_ond.php on line 24

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" media="screen"><!--
#layer1 { height: 370px; width: 560px; left: 260px; top: 150px; position: absolute; visibility: visible; }
--></style>
</head>

<body>

<?php
session_start();
require("config.php");
?>
<a href="main_newtopic.php" target="forummenu">New Topic</a><br><br>
<table border=1 cellpadding=0 cellspacing=0 width="50%">
<th class="kop" colspan="4"><h1>Main Forum</h1></th>
<tr><td class="sub">&nbsp;</td><td>Topic</td><td>Replies</td><td class="sub">&nbsp;</td></tr>
<?
$eind = 5;
$a = ($nav*$eind)-$eind;

$this->pages = $totaal / $eind;
$this->pages = ceil($this->pages);
$dbres = mysql_query("SELECT * FROM main_topics ORDER BY id ASC LIMIT $a,$eind");
while($topic = mysql_fetch_array($dbres)){
$sqldb = mysql_query("SELECT * FROM main_replies WHERE topic_id='$topic[id]'");
$replies = mysql_num_rows($sqldb);
?>
<tr><td class="sub">&nbsp;</td><td><a target="content" href="main_viewtopic.php?topic_id=<?=$topic['id']; ?>&nav=1"><?=$topic['title']; ?></a></td><td><?=$replies; ?></td><td class="sub">&nbsp;</td></tr>
<?
}
?>
</table>
<br><br>
<table border=1 cellpadding=0 cellspacing=0 width="50%">
<tr><td>
<?

if($nav == 1 OR $nav < 1){
echo "Previous";
}else{
?>
<a href="">Previous</a><?}?> <a href="">Next</a><br>
</td></tr></table>

</body>
</html></div>
</body>
</html>

dumpfi
08-04-2005, 12:31 PM
Well, the error states the problem: You use $this out of object context. (You cannot declare a variable with name "$this")

If you want to use an object of a class you must instantiate it before you can access its methods and properties:
class SomeClass {
public $anything = 'x';
public function something() {
// ...
}
//...
}

$someClassObj = new SomeClass();
$someClassObj->anything = 'X';
$someClassObj->something();dumpfi

sytodave88
08-04-2005, 12:47 PM
can someone show me where to put it or chage it for me