Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


cant seem to get my forums to work.

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Sun Nov 30, 2008 2:51 pm    Post subject: cant seem to get my forums to work. Reply with quote

here is my forum-index.php

Code:
<?php
session_start();
include'./global.php';

$action = $_GET['act'];
$actions_array = array('forum');
?>
<html>

<head>

<title>Nostrich's Forum</title>

<link rel="stylesheet" href="./style3.css" type="text/css" />

</head>

<body>

<center>

<div id="holder">

<div id="userInfo">

<?php

if($_SESSION['uid']){
$sql = "SELECT * FROM users WHERE id = '" . $_SESSION['uid'] . "'";
$res = mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res) == 0){
session_destroy();
echo "Please <a href='login2.php'>Login</a> to your account, or <a href='reg.php'>Register</a> a new account!\n";
}else{
$row = mysql_fetch_assoc($res);
echo "Welcome back,<a href=\"./forum-index.php?act=profile&id=".$row['id']."\">".$row['username']."</a>! <a href=\"./logout.php\">Logout</a>\n";
echo "<br>\n";
echo " <a href=\"./forum-index.php\">Forum Index</a>\n";
if($row['admin'] == '1'){
echo " | <a href=\"./admin.php\">Adminastrators section</a>\n";
}
}
}else{
echo "Please <a href='login2.php'>Login</a> to your account, or <a href='reg.php'>Register</a> a new account!\n";
}

?>

</div>

<div id="content">
<?php

if(!$action || !in_array($action,$actions_array)){
$sql1 = "SELECT * FROM forum_cats WHERE admin < ".$row['admin']. "+1";
$res1 = mysql_query($sql1) or die(mysql_error());

$i=1;

while ($row2 = mysql_fetch_assoc($res1)){
echo "<div id='fcontent'>\n";
echo "<div class='header' id=\"header_".$i."\" onMouseOver=\"this.className='headerb'\" onMouseOut=\"this.className='header'\">".$row2['name']."</div>\n";

$sql2 = "SELECT * FROM forum_sub_cats WHERE cid='".$row2['id']."' AND admin < ".$row['admin']."+1";
$res2 = mysql_query($sql2) or die(mysql_error());
while($row3 = mysql_fetch_assoc($res2)){
echo "<div id='content'>\n";
echo "<a href=\"./forum-index.php?act=forum&id=".$row3['id']."\">".$row3['name']."</a><br>\n";
echo "   " .$row3['desc'] . "\n";
echo "</div>\n";
}

echo "</div>\n";
$i++;
}
}else{
if($action == 'forum'){
include "./includes/forum.php";
}
}

?>
</div>

</div>

</center>

</body>

</html>


and forum.php in the includes folder!
Code:
<?php

$id = mss($_GET['id']);

if($id){
$sql = "SELECT * FROM forum_cats WHERE id='".$id."'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) == 0){
echo "The forum category you supplied does not exist!\n";
}
}

?>


but i have a few forums which do exist but it tells me that they dont!

what should i do????????
Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Sun Nov 30, 2008 8:29 pm    Post subject: Reply with quote

I created a test page using your code which you can view here -> http://cef.coolpage.biz/ghostrider.php?id=1. My table only has 3 entries, so try id=2, id=3, id=4 and so on.. to see the results.

ghostrider.php
Code:
<html>
<head>
<title>Hello</title>
</head>
<body>

<?php
include "mysql_connect.php";

// global.php
function mss($value)
{
   return mysql_real_escape_string(trim(strip_tags($value)));
}

// forum.php
$id = mss($_GET['id']);

if($id)
{
   $sql = "SELECT * FROM forum_cats WHERE id='".$id."'";
   $res = mysql_query($sql) or die(mysql_error());

   if(mysql_num_rows($res) == 0)
   {
      echo "The forum category you supplied does not exist!\n";
   }
   else
   {
      echo "<table border=\"1\"><tr><th>Id</th><th>Category</th><th>Description</th></tr>";

      while($row = mysql_fetch_assoc($res))
      {
         echo "<tr><td>$row[id]</td><td>$row[cat]</td><td>$row[desc]</td></tr>";
      }
      echo "</table>";
   }
}

mysql_close();
?>

</body>
</html>

I've added an else statement to show the db results on success, but other than that it's your (ugly Razz) code and works as expected?.. it's possible that your id's are mismatched with those of the table column id. I noticed in some of your sql queries you use "WHERE cid = .." instead of id?

Manually check your id variable against the id's in your table using phpMyAdmin to see if it points to the correct category.
Back to top
View user's profile Send private message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Mon Dec 01, 2008 10:11 am    Post subject: Reply with quote

thanks, this works now. u rock big time.

EDIT: I cant seem to get this echo to appear. BTW, i got rid of the table because i felt no nood for it.

this is forum.php now
Code:
<?php

$id = $_GET['id'];

if($id)
{
   $sql = "SELECT * FROM `forum_cats` WHERE `id`='".$id."'";
   $res = mysql_query($sql) or die(mysql_error());

   if(mysql_num_rows($res) == 0)
   {
      echo "The forum category you supplied does not exist!\n";
   }
else{
$row = mysql_fetch_assoc($res);
if($row['admin'] == 1 && $admin_user_level == 0){
echo "You must be an admin to view this forum!\n";
}else{
$sql2 =  "SELECT * FROM `forum_topics` WHERE `cid`='".$row['id']."'";
$res2 = mysql_query($sql2) or die mysql_error());
if(mysql_num_rows($res2) == 0){
echo "There are no topics in this forum, <a href=\"./forum-index.php?act=create&id=".$row['id']."\">click here</a> to create a topic!\n";
}
}
}
}
?>


the line that i'm having trouble with now is

Code:
echo "There are no topics in this forum, <a href=\"./forum-index.php?act=create&id=".$row['id']."\">click here</a> to create a topic!\n";
Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Mon Dec 01, 2008 11:19 am    Post subject: Reply with quote

Code:
echo "There are no topics in this forum, <a href=\"/forum-index.php?act=create&id=$row[id]\">click here</a> to create a topic!\n";
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon Dec 01, 2008 11:23 am    Post subject: Reply with quote

or
Code:
echo 'There are no topics in this forum, <a href="/forum-index.php?act=create&id=$row[id]">click here</a> to create a topic!\n';
Back to top
View user's profile Send private message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Mon Dec 01, 2008 11:24 am    Post subject: Reply with quote

still didn't work. maybe it's something else in the code?

none of them work!
Back to top
View user's profile Send private message
Reak
I post too much
Reputation: 0

Joined: 15 May 2007
Posts: 3496

PostPosted: Mon Dec 01, 2008 11:39 am    Post subject: Reply with quote

hmm try this:

Code:
<?php

function isInteger($input){
  return preg_match('@^[-]?[0-9]+$@',$input) === 1;
}

function ShowTopics($forumid){
   $sql =  "SELECT * FROM `forum_topics` WHERE `cid`=$forumid";
   $res = mysql_query($sql) or die(mysql_error());
   if(mysql_num_rows($res) == 0){
      echo 'There are no topics in this forum, <a href="/forum-index.php?act=create&id=$row[id]">click here</a> to create a topic!\n';
   } else {
      echo "forum..<br />";
   }
}

$id = $_GET['id'];


if(isInteger($id)){
   $sql = "SELECT * FROM `forum_cats` WHERE `id`=$id";
   $res = mysql_query($sql) or die(mysql_error());

   if(mysql_num_rows($res) == 0){
      echo "The forum category you supplied does not exist!\n";
   } else {
      $row = mysql_fetch_assoc($res);
      if($row['admin'] > 0){
         if($admin_user_level > 0){
            ShowTopics($row['id']);
         } else {
            echo "You must be an admin to view this forum!\n";
         }
      } else {
         ShowTopics($row['id']);
      }
   }
}
?>



Note: I edited a bit so it's more secure from SQL-injection.

Tell me if it works.
Back to top
View user's profile Send private message
deleted user 111213
Grandmaster Cheater
Reputation: 0

Joined: 09 Nov 2007
Posts: 714

PostPosted: Mon Dec 01, 2008 12:35 pm    Post subject: Reply with quote

thanks, that worked. but i'm just going to finish create.php But now it says some of them don't exist again. and also i'm having even more trouble. i'm trying to make a drop down box of where the user wants to post, but it doesn't show up as well as the id of the post.

create.php code
Code:
<?php

$id = $_GET['id'];

if($id){
$sql = "SELECT * FROM forum_sub_cats WHERE id='".$id."'";
$res = mysql_query($sql) or die(mysql_error());
if(mysql_num_rows($res) == 0){
echo "The forum you are trying to create a topic on doesn't exist!\n";
}else{
$row1 = mysql_fetch_assoc($res);
if($row1['admin'] == 1 && $admin_user_level == 0){
echo "You are not an admin, you ,cannot post here!\n";
}else{
echo "<table border='0' cellspacing='3' cellpadding='3'>\n";
echo "<form method='post' action='forum-index.php?act=create'>\n";
echo "<tr><td>Forum Sub Category</td><td><select name='cat'>\n";
$sql2 = "SELECT * FROM forum_cats WHERE admin < ".$admin_user_level."+1";
$res2 = mysql_query($sql2) or die mysql_error());
while ($row = mysql_fetch_assoc($res2)){
$sql3 = "SELECT * FROM forum_sub_cats WHERE id='".$row['id']."'";
$res3 = mysql_query($sql3) or die(mysql_error());

echo "<option value='0'>".$row['name']."</option>\n";
while ($row2 = mysql_fetch_assoc($res3)){
$selected = ($row2['id'] == $id) ? " SELECTED " : "";
echo "<option value=\"".$row2['id']."\"".$selected.">     ".$row2['name']."</option>\n";
}
}
echo "</select></td></tr>\n";
}
}
}

?>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites