Jump to content

Club error


eaglelegend

Recommended Posts

http://eaglelegend.com/club.php?game=1&clubid=1

 

Hey guys, again, its me, with another issiue, all my sites "clubs" show - oddly enough - NO Owner name, NO hits and somehow XD they are apparently were all made in Dec 31, 1969.

 

This is the current code for clubs.inc.php (club.php judt shows include files)

 

<?php

/*

Club include (club.inc.php)

*/
$clubid = $_GET['clubid'];
mysql_query("UPDATE clubs2 SET hits = hits + 1 WHERE id = '$clubid' AND game = '$game'") or die (mysql_error());

$getclub = mysql_query("SELECT * FROM clubs2 WHERE id = '$clubid' AND game = '$game'") or die (mysql_error());
if (mysql_num_rows($getclub) == 0)
{
die(header(error("club.php?game=$game","This is not a real club.")));
}
$getmemberdata = fetch("SELECT * FROM club_members2 WHERE club = '$clubid' AND user = '$userid' AND game = '$game'");
$getmemberdata4 = fetch("SELECT * FROM club_members2 WHERE user = '$userid' AND game = '$game'");
if (!$getmemberdata[id])
{
$getmemberdata[position] = 0;
}
$clubrank = $getmemberdata[position];

if ($clubrank == 0)
{
$position = "Visitor, <a href=$base_url/club_join.pro.php?game=$game&clubid=$clubid><font color=$topAndBottomText>join</font></a>";
}

if ($clubrank == 1)
{
$position = "Member, <a href=$base_url/club_leave.pro.php?game=$game&clubid=$clubid onClick=\"if ( !confirm ('Are you sure you want to leave this club?') ) { return false; }\"><font color=$topAndBottomText>leave</font></a>";
}
if ($clubrank == 2)
{
$position = "Moderator, <a href=$base_url/club_leave.pro.php?game=$game&clubid=$clubid onClick=\"if ( !confirm ('Are you sure you want to leave this club?') ) { return false; }\"><font color=$topAndBottomText>leave</font></a>";
}
if ($clubrank == 3)
{
$position = "Admin";
$club_admin_line = "<br><a href=club_admin.php?game=$game&clubid=$clubid>Admin Page</a>";
}

if ($clubrank < $clubrank_check)
{
die(header(error("clubs.php?game=$game","You do not have access to this page.")));
}

$num_members = mysql_num_rows(mysql_query("SELECT id FROM club_members2 WHERE club = '$clubid' AND game = '$game'"));
$date_created = date("M j, Y",$getclub[datecreated]);
$owner = fetch("SELECT display_name FROM members2 WHERE id = '$getclub[owner]' AND game = '$game'");

$numPosts = mysql_num_rows(mysql_query("SELECT id FROM club_forums2 WHERE club = '$clubid'"));

$topmenu = "
<center><table width=95% bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1><tr bgcolor=\"$topAndBottomBG\" width=100%><td><p><font color=$topAndBottomText><b>$getclub[name]</b> <i>owned by $owner[display_name]</i></font></p></td><td width=150><p><font color=$topAndBottomText>$display_name ($position)</font></p></td></tr><tr height=100 bgcolor=\"$reallyLight\"><TD colspan=2><p align=center><b><i>$getclub[motto]</i></b></p><center><table bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1 width=375><tr bgcolor=\"$topAndBottomBG\"><td width=50%><p align=center><b><font color=$topAndBottomText>Stats</font></b></p></td><td width=50%><p align=center><b><font color=$topAndBottomText>Links</font></b></p></td></tr><tr bgcolor=\"$reallyLight\"><td valign=top>

<p>Members: <a href=club_members.php?game=$game&clubid=$clubid>$num_members</a><br>
Created: $date_created<Br>
Hits: $getclub[hits]</p>

</td><td valign=top>

<p><a href=$base_url/club.php?game=$game&clubid=$clubid>Home</a><br>
<a href=$base_url/club_forums.php?game=$game&clubid=$clubid>Chat Boards</a> ($numPosts Posts)
$club_admin_line</p></td>

</tr></table><Br></center></td></tr></table>";

$startClub = "<Br>$topmenu<br><table width=95% bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1><tr bgcolor=\"$topAndBottomBG\"><td><p align=left class=white><b>$page_heading</b></p></td></tr><tr bgcolor=\"$maincellColor\"><td>";
$endClub = "</td></tr></table></center><br>";

?>

 

Please help, thanks! :)

Link to comment
Share on other sites

As for the date, this line

<?php
$date_created = date("M j, Y",$getclub[datecreated]);
?>

probably should be

<?php
$date_created = date("M j, Y",strtotime($getclub['datecreated']));
?>

 

Also, what does $getclub['datecreated'] contain?

 

Ken

 

 

Link to comment
Share on other sites

it may be a timestamp?; look at the create a club page;

 

<?php

/*

Create club (club_create.pro.php)

*/
ob_start();
$rank_check = 1;
include "global.inc.php";

$clubcheck = fetch("SELECT id FROM clubs2 WHERE owner = '$userid' AND game = '$game'");
if ($clubcheck[id])
{
die(header(error("club.php?game=$game","You can only have one club.")));
}
$check = check_length($club_name,24);
if ($check == 0)
{
die(header(error("club_create.php?game=$game","Your club's name can only be 24 characters.")));
}
$check = check_length($club_motto,64);
if ($check == 0)
{
die(header(error("club_create.php?game=$game","Your club's motto can only be 64 characters.")));
}
$check = check_length($description,10000);
if ($check == 0)
{
die(header(error("club_create.php?game=$game","Your club's description can only be 10000 characters.")));
}

if ($private != 1)
{
$private = 0;
}

if (stripspaces($club_name) == "")
{
die(header(error("club_create.php?game=$game","Do not leave your club's name blank.")));
}
if (stripspaces($club_motto) == "")
{
die(header(error("club_create.php?game=$game","Do not leave your club's motto blank.")));
}

if (stripspaces($description) == "")
{
die(header(error("club_create.php?game=$game","Do not leave your club's description blank.")));
}

mysql_query("INSERT INTO clubs2 (name,motto,owner,datecreated,private,game,keywords,members) VALUES ('$club_name','$club_motto','$userid','$timestamp','$privacy','$game','$keywords','1')") or die(mysql_error());

$id = mysql_insert_id();

mysql_query("INSERT INTO club_pages2 (club,page,name,data,game) VALUES ('$id','1','home','$description','$game')") or die(mysql_error());

mysql_query("INSERT INTO club_members2 (club,user,position,game) VALUES ('$id','$userid','3','$game')") or die(mysql_error());

header(error("clubs.php?game=$game&clubid=$id","Your club has been created."));

?>

 

am I correct?

Link to comment
Share on other sites

I did a quick test:

<?php
$getclub = array();
$getclub['datecreated'] = 1225456495;
$date_created = date("M j, Y",$getclub['datecreated']);
echo $date_created;
?>

This is the result:

Oct 31, 2008

 

Do you get a different result?

 

Ken

Link to comment
Share on other sites

<?php

/*

Club include (club.inc.php)

*/
$clubid = $_GET['clubid'];
mysql_query("UPDATE clubs2 SET hits = hits + 1 WHERE id = '$clubid' AND game = '$game'") or die (mysql_error());

$getclub = mysql_query("SELECT * FROM clubs2 WHERE id = '$clubid' AND game = '$game'") or die (mysql_error());
if (mysql_num_rows($getclub) == 0)
{
die(header(error("club.php?game=$game","This is not a real club.")));
}
$getmemberdata = fetch("SELECT * FROM club_members2 WHERE club = '$clubid' AND user = '$userid' AND game = '$game'");
$getmemberdata4 = fetch("SELECT * FROM club_members2 WHERE user = '$userid' AND game = '$game'");
if (!$getmemberdata[id])
{
$getmemberdata[position] = 0;
}
$clubrank = $getmemberdata[position];

if ($clubrank == 0)
{
$position = "Visitor, <a href=$base_url/club_join.pro.php?game=$game&clubid=$clubid><font color=$topAndBottomText>join</font></a>";
}

if ($clubrank == 1)
{
$position = "Member, <a href=$base_url/club_leave.pro.php?game=$game&clubid=$clubid onClick=\"if ( !confirm ('Are you sure you want to leave this club?') ) { return false; }\"><font color=$topAndBottomText>leave</font></a>";
}
if ($clubrank == 2)
{
$position = "Moderator, <a href=$base_url/club_leave.pro.php?game=$game&clubid=$clubid onClick=\"if ( !confirm ('Are you sure you want to leave this club?') ) { return false; }\"><font color=$topAndBottomText>leave</font></a>";
}
if ($clubrank == 3)
{
$position = "Admin";
$club_admin_line = "<br><a href=club_admin.php?game=$game&clubid=$clubid>Admin Page</a>";
}

if ($clubrank < $clubrank_check)
{
die(header(error("clubs.php?game=$game","You do not have access to this page.")));
}

$num_members = mysql_num_rows(mysql_query("SELECT id FROM club_members2 WHERE club = '$clubid' AND game = '$game'"));
$date_created = date("M j, Y",strtotime($getclub['datecreated']));
$owner = fetch("SELECT display_name FROM members2 WHERE id = '$getclub[owner]' AND game = '$game'");

$numPosts = mysql_num_rows(mysql_query("SELECT id FROM club_forums2 WHERE club = '$clubid'"));

$topmenu = "
<center><table width=95% bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1><tr bgcolor=\"$topAndBottomBG\" width=100%><td><p><font color=$topAndBottomText><b>$getclub[name]</b> <i>owned by $owner[display_name]</i></font></p></td><td width=150><p><font color=$topAndBottomText>$display_name ($position)</font></p></td></tr><tr height=100 bgcolor=\"$reallyLight\"><TD colspan=2><p align=center><b><i>$getclub[motto]</i></b></p><center><table bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1 width=375><tr bgcolor=\"$topAndBottomBG\"><td width=50%><p align=center><b><font color=$topAndBottomText>Stats</font></b></p></td><td width=50%><p align=center><b><font color=$topAndBottomText>Links</font></b></p></td></tr><tr bgcolor=\"$reallyLight\"><td valign=top>

<p>Members: <a href=club_members.php?game=$game&clubid=$clubid>$num_members</a><br>
Created: $date_created<Br>
Hits: $getclub[hits]</p>

</td><td valign=top>

<p><a href=$base_url/club.php?game=$game&clubid=$clubid>Home</a><br>
<a href=$base_url/club_forums.php?game=$game&clubid=$clubid>Chat Boards</a> ($numPosts Posts)
$club_admin_line</p></td>

</tr></table><Br></center></td></tr></table>";

$startClub = "<Br>$topmenu<br><table width=95% bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1><tr bgcolor=\"$topAndBottomBG\"><td><p align=left class=white><b>$page_heading</b></p></td></tr><tr bgcolor=\"$maincellColor\"><td>";
$endClub = "</td></tr></table></center><br>";

?>

 

This includes the modification you suggested. (club.inc.php - include file for clubs)

Link to comment
Share on other sites

Put a debugging statement in:

<?php
echo '<pre>' . var_export($getclub,true) . '</pre>'
$date_created = date("M j, Y",$getclub['datecreated']);
?>

 

This will dump the contents of $getclub, so we can see what's really going on.

 

Ken

Link to comment
Share on other sites

Yes, I forgot the ";", sorry.

 

If you're getting NULL, then the array, $getclub, doesn't contain what you think it should. That's because this line

<?php
$getclub = mysql_query("SELECT * FROM clubs2 WHERE id = '$clubid' AND game = '$game'") or die (mysql_error());
?>

only returns a pointer to the returned set, not the set itself. Change that to

<?php
$q = "SELECT * FROM clubs2 WHERE id = '$clubid' AND game = '$game'";
$rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
$getclub = mysql_fetch_assoc($rs);
?>

 

Ken

 

 

 

Link to comment
Share on other sites

Thanks - The problem I have now it is saying "Redirect loop";

<?php

/*

Club include (club.inc.php)

*/
$clubid = $_GET['clubid'];
mysql_query("UPDATE clubs2 SET hits = hits + 1 WHERE id = '$clubid' AND game = '$game'") or die (mysql_error());

$q = "SELECT * FROM clubs2 WHERE id = '$clubid' AND game = '$game'";
$rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
$getclub = mysql_fetch_assoc($rs);
if (mysql_num_rows($getclub) == 0)
{
die(header(error("club.php?game=$game","This is not a real club.")));
}
$getmemberdata = fetch("SELECT * FROM club_members2 WHERE club = '$clubid' AND user = '$userid' AND game = '$game'");
$getmemberdata4 = fetch("SELECT * FROM club_members2 WHERE user = '$userid' AND game = '$game'");
if (!$getmemberdata[id])
{
$getmemberdata[position] = 0;
}
$clubrank = $getmemberdata[position];

if ($clubrank == 0)
{
$position = "Visitor, <a href=$base_url/club_join.pro.php?game=$game&clubid=$clubid><font color=$topAndBottomText>join</font></a>";
}

if ($clubrank == 1)
{
$position = "Member, <a href=$base_url/club_leave.pro.php?game=$game&clubid=$clubid onClick=\"if ( !confirm ('Are you sure you want to leave this club?') ) { return false; }\"><font color=$topAndBottomText>leave</font></a>";
}
if ($clubrank == 2)
{
$position = "Moderator, <a href=$base_url/club_leave.pro.php?game=$game&clubid=$clubid onClick=\"if ( !confirm ('Are you sure you want to leave this club?') ) { return false; }\"><font color=$topAndBottomText>leave</font></a>";
}
if ($clubrank == 3)
{
$position = "Admin";
$club_admin_line = "<br><a href=club_admin.php?game=$game&clubid=$clubid>Admin Page</a>";
}

if ($clubrank < $clubrank_check)
{
die(header(error("clubs.php?game=$game","You do not have access to this page.")));
}

$num_members = mysql_num_rows(mysql_query("SELECT id FROM club_members2 WHERE club = '$clubid' AND game = '$game'"));
echo '<pre>' . var_export($getclub,true) . '</pre>';
$date_created = date("M j, Y",$getclub['datecreated']);
$owner = fetch("SELECT display_name FROM members2 WHERE id = '$getclub[owner]' AND game = '$game'");

$numPosts = mysql_num_rows(mysql_query("SELECT id FROM club_forums2 WHERE club = '$clubid'"));

$topmenu = "
<center><table width=95% bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1><tr bgcolor=\"$topAndBottomBG\" width=100%><td><p><font color=$topAndBottomText><b>$getclub[name]</b> <i>owned by $owner[display_name]</i></font></p></td><td width=150><p><font color=$topAndBottomText>$display_name ($position)</font></p></td></tr><tr height=100 bgcolor=\"$reallyLight\"><TD colspan=2><p align=center><b><i>$getclub[motto]</i></b></p><center><table bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1 width=375><tr bgcolor=\"$topAndBottomBG\"><td width=50%><p align=center><b><font color=$topAndBottomText>Stats</font></b></p></td><td width=50%><p align=center><b><font color=$topAndBottomText>Links</font></b></p></td></tr><tr bgcolor=\"$reallyLight\"><td valign=top>

<p>Members: <a href=club_members.php?game=$game&clubid=$clubid>$num_members</a><br>
Created: $date_created<Br>
Hits: $getclub[hits]</p>

</td><td valign=top>

<p><a href=$base_url/club.php?game=$game&clubid=$clubid>Home</a><br>
<a href=$base_url/club_forums.php?game=$game&clubid=$clubid>Chat Boards</a> ($numPosts Posts)
$club_admin_line</p></td>

</tr></table><Br></center></td></tr></table>";

$startClub = "<Br>$topmenu<br><table width=95% bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1><tr bgcolor=\"$topAndBottomBG\"><td><p align=left class=white><b>$page_heading</b></p></td></tr><tr bgcolor=\"$maincellColor\"><td>";
$endClub = "</td></tr></table></center><br>";

?>

Link to comment
Share on other sites

thanks for that - that got rid of the redirect, however the testcode you gavwe me still states null and the date is still that 1969 date.

 

The error is basically goes on the URL like error+that+club+dont+exsist and also it posts it on the page that they are viewing - if it dont exsist - I very much suggest you visit the sites yourself, or join up so you can actually see what I am...

Link to comment
Share on other sites

<?php



/*



Club include (club.inc.php)



*/

$clubid = $_GET['clubid'];

mysql_query("UPDATE clubs2 SET hits = hits + 1 WHERE id = '$clubid' AND game = '$game'") or die (mysql_error());



$q = "SELECT * FROM clubs2 WHERE id = '$clubid' AND game = '$game'";
$rs = mysql_query($q) or die("Problem with the query: $q<br>" . mysql_error());
$getclub = mysql_fetch_assoc($rs);

if (mysql_num_rows($getclub) == 0)

{

die(header(error("club.php?game=$game","This is not a real club.")));

}

$getmemberdata = fetch("SELECT * FROM club_members2 WHERE club = '$clubid' AND user = '$userid' AND game = '$game'");

$getmemberdata4 = fetch("SELECT * FROM club_members2 WHERE user = '$userid' AND game = '$game'");

if (!$getmemberdata[id])

{

$getmemberdata[position] = 0;

}

$clubrank = $getmemberdata[position];



if ($clubrank == 0)

{

$position = "Visitor, <a href=$base_url/club_join.pro.php?game=$game&clubid=$clubid><font color=$topAndBottomText>join</font></a>";

}



if ($clubrank == 1)

{

$position = "Member, <a href=$base_url/club_leave.pro.php?game=$game&clubid=$clubid onClick=\"if ( !confirm ('Are you sure you want to leave this club?') ) { return false; }\"><font color=$topAndBottomText>leave</font></a>";

}

if ($clubrank == 2)

{

$position = "Moderator, <a href=$base_url/club_leave.pro.php?game=$game&clubid=$clubid onClick=\"if ( !confirm ('Are you sure you want to leave this club?') ) { return false; }\"><font color=$topAndBottomText>leave</font></a>";

}

if ($clubrank == 3)

{

$position = "Admin";

$club_admin_line = "<br><a href=club_admin.php?game=$game&clubid=$clubid>Admin Page</a>";

}



if ($clubrank < $clubrank_check)

{

die(header(error("clubs.php?game=$game","You do not have access to this page.")));

}



$num_members = mysql_num_rows(mysql_query("SELECT id FROM club_members2 WHERE club = '$clubid' AND game = '$game'"));

echo '<pre>' . var_export($getclub,true) . '</pre>';

$date_created = date("M j, Y",$getclub['datecreated']);

$owner = fetch("SELECT display_name FROM members2 WHERE id = '$getclub[owner]' AND game = '$game'");



$numPosts = mysql_num_rows(mysql_query("SELECT id FROM club_forums2 WHERE club = '$clubid'"));



$topmenu = "

<center><table width=95% bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1><tr bgcolor=\"$topAndBottomBG\" width=100%><td><p><font color=$topAndBottomText><b>$getclub[name]</b> <i>owned by $owner[display_name]</i></font></p></td><td width=150><p><font color=$topAndBottomText>$display_name ($position)</font></p></td></tr><tr height=100 bgcolor=\"$reallyLight\"><TD colspan=2><p align=center><b><i>$getclub[motto]</i></b></p><center><table bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1 width=375><tr bgcolor=\"$topAndBottomBG\"><td width=50%><p align=center><b><font color=$topAndBottomText>Stats</font></b></p></td><td width=50%><p align=center><b><font color=$topAndBottomText>Links</font></b></p></td></tr><tr bgcolor=\"$reallyLight\"><td valign=top>



<p>Members: <a href=club_members.php?game=$game&clubid=$clubid>$num_members</a><br>

Created: $date_created<Br>

Hits: $getclub[hits]</p>



</td><td valign=top>



<p><a href=$base_url/club.php?game=$game&clubid=$clubid>Home</a><br>

<a href=$base_url/club_forums.php?game=$game&clubid=$clubid>Chat Boards</a> ($numPosts Posts)

$club_admin_line</p></td>



</tr></table><Br></center></td></tr></table>";



$startClub = "<Br>$topmenu<br><table width=95% bgcolor=\"$tableOutline\" cellpadding=0 cellspacing=1><tr bgcolor=\"$topAndBottomBG\"><td><p align=left class=white><b>$page_heading</b></p></td></tr><tr bgcolor=\"$maincellColor\"><td>";

$endClub = "</td></tr></table></center><br>";



?>

 

ok, I just tried the "this is not a real club one" one without the header and one without the die, however without the die it loops - like it is doing with the current code. however without header it just comes up "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/webredev/public_html/eaglelegend/club.inc.php on line 12

Location: club.php?game=1&error=This+is+not+a+real+club."

 

and well, if you want, I could give you access to the database - to check that out,if you need.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.