Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> For Hire
Author Message
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Sun Aug 08, 2010 6:23 pm Reply with quote

Zip it up and pm me a link.

_________________
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan. 
View user's profile Send private message
rebelt
Worker
Worker



Joined: May 07, 2006
Posts: 172

PostPosted: Mon Aug 09, 2010 1:47 pm Reply with quote

pm sent.
 
View user's profile Send private message Visit poster's website
rebelt







PostPosted: Tue Aug 10, 2010 3:14 am Reply with quote

With regard to the teams script. I'm trying to place the whole script into a module (leaving the separation of public/admin for now) just to get it functioning, so I can deactivate it temporarily for a few days to stop information being entered.

Things seemed to be going well until I came up against this error.
Quote:
Fatal error: Call to a member function sql_query() on a non-object in /..../../..../../..../modules/Teams2/index.php on line 1007

Code:
### Submitted Team Allocations


function submittedteamallocations($user, $allchanges)
{
 $username=getusername($user);

 if ($username=="user" | $username=="RebelT")
 {

 $pieces = explode("|", $allchanges);
 $ii = count($pieces)-1;
 for($i=0;$i<$ii;$i++)
 {
  $thisvalue = explode("=", $pieces[$i]);

****************This is line 1007******************
$db->sql_query("update team_names2 set division='$thisvalue[1]' where team_id='$thisvalue[0]'");

# echo "update team_names2 set division='$thisvalue[1]' where team_id='$thisvalue[0]'<BR>";
 }
# echo urlforward("http://rebelt.westonpoolleague.org.uk/modules.php?name=Teams2&op=Admin");

$url = "http://rebelt.westonpoolleague.org.uk/modules.php?name=Teams2&op=Admin";
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.$url.'">';
 }
}


Just trying to get this working by Thursday, which is hard when I don't even know what a non object is. Embarassed

Sorry if I'm being a pain. I must come accross as a desperate, clueless, idiot. Well I suppose with this I am. Very Happy
 
Palbin







PostPosted: Tue Aug 10, 2010 5:04 am Reply with quote

In the admin you need to finished the switch statement at the bottom. Google "PHP switch statement" and make sure you have a default. The switch statement should be call your functions.

For the fatal error try adding a "global $db;" at the top of the page or function you are using.
 
rebelt







PostPosted: Tue Aug 10, 2010 7:11 am Reply with quote

Changed the switch statements to
Code:
<?PHP

if (!defined('ADMIN_FILE')) die ('Access Denied');

require_once 'mainfile.php';
###
### List Results In Admin
###

function listresults()
{
 include ('header.php');
 global $admin;

      Header("Location: ".$admin_file.".php?op=list");

$result = mysql_query("select match_id, home_team, away_team, home_score, away_score, division, email, match_date from team_scores where status=0 order by division");

$thiscount=1;

echo "<font size=4><B>Results Admin</b></font size=4>";
echo "<font size=2><center><b>Pending Results</b></center><br><BR></font>";
echo "<BR><table width=100%>";
$lastdivision="9";

while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $email, $match_date) = mysql_fetch_row($result))
 {
  if ($division!=$lastdivision)
  {
  echo "<tr><td colspan=4 align=center><font size=4><b>Division $division</b></font size=4></td></tr>";
  }
   $matchdate = date("Y-m-d", strtotime($match_date));
   $displaymatchdate = date("d-m-Y", strtotime($match_date));
   $email2 = str_replace('.', ',', $email);

  echo"<tr><td>$match_id $displaymatchdate $email  </td><TD>$home_team $home_score</TD><TD>$away_team</td><TD>$away_score</TD><td><td><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a>&nbsp;&nbsp; <a href=leagueresult.php?op=adminmakelive&id=$match_id>Make Live</a></font></td></tr>";
  $thiscount=$thiscount+1;
  $lastdivision=$division;
 }

echo "</table><BR>";

  mysql_free_result($result);

$result = mysql_query("select match_id, home_team, away_team, home_score, away_score, division, email, match_date, status, comments from team_scores where status>0 order by division");

echo "<font size=2><center><b>Live Results</b></center><br><BR></font>";
echo "<BR><table width=100%>";
$lastdivision="9";

while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $email, $match_date, $status, $comments) = mysql_fetch_row($result))
 {
  if ($division!=$lastdivision)
  {
  echo "<tr><td colspan=4 align=center><font size=4><b>Division $division</b></font size=4></td></tr>";
  }
   $matchdate = date("Y-m-d", strtotime($match_date));
   $displaymatchdate = date("d-m-Y", strtotime($match_date));
   $email2 = str_replace('.', ',', $email);
  if ($status=='3')
  {
   echo"<tr><td>$match_id $displaymatchdate $email </td><TD></TD><TD></td><TD></TD><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a></font></td></tr>";
  }
  else
  {
   echo"<tr><td>$match_id $displaymatchdate $email</td><TD>$home_team  $home_score</TD><TD>$away_team</td><TD>$away_score</TD><td><td><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a></font></td></tr>";
  }
  $thiscount=$thiscount+1;
  $lastdivision=$division;
 }

echo "</table><BR><BR><BR><a href=\"leagueresult.php\">Live results page</a>";
  mysql_free_result($result);



 include ("footer.php");
}


###
### Admin Delete
###

function admin_delete_result($id, $validate)
{

$email = str_replace(',', '.', $validate);

  mysql_query("delete from team_scores where match_id='$id'");
 if (mysql_affected_rows()==0)
 {
  dispmessage('nosuchmatchID', $id);
 }
 else
 {
  dispmessage('deleted', $id);
  Header("Location: ".$admin_file.".php?op=list");

 }
}

###
### Admin Make Live
###

function admin_makelive_result($id)
{
 mysql_query("update team_scores set status='1' where match_id='$id'");
 if (mysql_affected_rows()==0)
 {
  dispmessage('nosuchmatchID', $id);
 }
 else
 {
  dispmessage('authorised', $id);
 }
}

switch($_REQUEST['op']) {

    case "adminmakelive":
   admin_makelive_result($_REQUEST['id']);
   break;
   
    case "admindelete":
   admin_delete_result($_REQUEST['id'], $_REQUEST['validate']);
   break;
   
    default:
   listresults();
   break;

}
?>

But still same error.

Re the fatal error. Added global $db; to the top of the page which moved the error to line 1254.
Code:
 $result = $db->sql_query("select authorisation_user from team_authorisation where authorisation_teamid='$teamid'");



Tried global $db, $result; above the function but no change
 
Palbin







PostPosted: Tue Aug 10, 2010 7:20 pm Reply with quote

To get your admin to at least show. Make sure to not the changes in these two files.

case.php
Code:


if (!defined('ADMIN_FILE')) {
   die ('Access Denied');
}

$module_name = basename(dirname(dirname(__FILE__)));

switch($op) {
   case 'listresults':
   case 'adminmakelive':
   case 'admindelete':
      require 'modules/' . $module_name . '/admin/index.php';
      break;
}


links.php
Code:


if (!defined('ADMIN_FILE')) {
   die ('Access Denied');
}

global $admin_file;

adminmenu($admin_file . '.php?op=listresults', 'Results', 'results.gif');


In the index in your last post you need to comment out line 14
Code:


Header("Location: ".$admin_file.".php?op=list");


Remember what ever cases are in the case,php need to be in the switch at the bottom of the index.

There is a lot of work to do in there. I suggest looking at one of the simple modules as an example. I suggest looking at Reviews.
 
rebelt







PostPosted: Thu Aug 12, 2010 12:10 pm Reply with quote

Quote:
There is a lot of work to do in there.

Crikey Shocked and you know what you're doing. I'll do as you suggested and try to stumble through

Thanks for your help.
 
rebelt







PostPosted: Mon Aug 16, 2010 12:44 pm Reply with quote

Well thanks to Palbin I at least managed to get this to display errors.

Got rid of the first 2 but now get
Parse error: syntax error, unexpected $end ..\..\..\..\...\....\....\index.php on line 146

Thats the end tag so am now totally confused. Can't find any missing brackets.

Spent three days on this.

Could someone please suggest as to who I could ask for a quote to take this on.

Latest effort. (incomplete)
Code:
<?php

if (!defined('ADMIN_FILE')) {
   die('Access Denied');
}
global $admin_file, $db, $prefix;

$aid = substr($aid, 0, 25);
$row = $db->sql_fetchrow($db->sql_query('SELECT title, admins FROM ' . $prefix . '_modules WHERE title=\'Leagueresult\''));
$row2 = $db->sql_fetchrow($db->sql_query('SELECT name, radminsuper FROM ' . $prefix . '_authors WHERE aid=\'' . $aid . '\''));
$admins = explode(',', $row['admins']);
$auth_user = 0;
for ($i = 0;$i < sizeof($admins);$i++) {
   if ($row2['name'] == $admins[$i] AND !empty($row['admins'])) {
      $auth_user = 1;
   }
}

if ($row2['radminsuper'] == 1 || $auth_user == 1) {
   if (!isset($op)) $op = 'reviews';

###
### List Results In Admin
###

function listresults()
{
 include ('header.php');
global $admin_file, $db, $prefix;

//      Header("Location: ".$admin_file.".php?op=list");

$result = $db->sql_query("select match_id, home_team, away_team, home_score, away_score, division, email, match_date from team_scores where status=0 order by division");

$thiscount=1;

echo "<font size=4><B>Results Admin</b></font size=4>";
echo "<font size=2><center><b>Pending Results</b></center><br><BR></font>";
echo "<BR><table width=100%>";
$lastdivision="9";

while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $email, $match_date) = mysql_fetch_row($result))
 {
  if ($division!=$lastdivision)
  {
  echo "<tr><td colspan=4 align=center><font size=4><b>Division $division</b></font size=4></td></tr>";
  }
   $matchdate = date("Y-m-d", strtotime($match_date));
   $displaymatchdate = date("d-m-Y", strtotime($match_date));
   $email2 = str_replace('.', ',', $email);

  echo"<tr><td>$match_id $displaymatchdate $email  </td><TD>$home_team $home_score</TD><TD>$away_team</td><TD>$away_score</TD><td><td><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a>&nbsp;&nbsp; <a href=leagueresult.php?op=adminmakelive&id=$match_id>Make Live</a></font></td></tr>";
  $thiscount=$thiscount+1;
  $lastdivision=$division;
 }

echo "</table><BR>";

  mysql_free_result($result);

$result = mysql_query("select match_id, home_team, away_team, home_score, away_score, division, email, match_date, status, comments from team_scores where status>0 order by division");

echo "<font size=2><center><b>Live Results</b></center><br><BR></font>";
echo "<BR><table width=100%>";
$lastdivision="9";

while (list($match_id, $home_team, $away_team, $home_score, $away_score, $division, $email, $match_date, $status, $comments) = mysql_fetch_row($result))
 {
  if ($division!=$lastdivision)
  {
  echo "<tr><td colspan=4 align=center><font size=4><b>Division $division</b></font size=4></td></tr>";
  }
   $matchdate = date("Y-m-d", strtotime($match_date));
   $displaymatchdate = date("d-m-Y", strtotime($match_date));
   $email2 = str_replace('.', ',', $email);
  if ($status=='3')
  {
   echo"<tr><td>$match_id $displaymatchdate $email </td><TD></TD><TD></td><TD></TD><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a></font></td></tr>";
  }
  else
  {
   echo"<tr><td>$match_id $displaymatchdate $email</td><TD>$home_team  $home_score</TD><TD>$away_team</td><TD>$away_score</TD><td><td><font size=1><a href=leagueresult.php?op=admindelete&id=$match_id>Delete</a></font></td></tr>";
  }
  $thiscount=$thiscount+1;
  $lastdivision=$division;
 }

echo "</table><BR><BR><BR><a href=\"leagueresult.php\">Live results page</a>";
  mysql_free_result($result);



 include ("footer.php");
}


###
### Admin Delete
###

function admin_delete_result($id, $validate)
{

$email = str_replace(',', '.', $validate);

  mysql_query("delete from team_scores where match_id='$id'");
 if (mysql_affected_rows()==0)
 {
  dispmessage('nosuchmatchID', $id);
 }
 else
 {
  dispmessage('deleted', $id);
 }
}

###
### Admin Make Live
###

function admin_makelive_result($id)
{
 mysql_query("update team_scores set status='1' where match_id='$id'");
 if (mysql_affected_rows()==0)
 {
  dispmessage('nosuchmatchID', $id);
 }
 else
 {
  dispmessage('authorised', $id);
 }
}

switch($_REQUEST['op']) {
    case "list":
   listresults();
   break;

    case "adminmakelive":
   admin_makelive_result($_REQUEST['id']);
   break;
    case "admindelete":
   admin_delete_result($_REQUEST['id'], $_REQUEST['validate']);
   break;

}
?>
 
nuken
RavenNuke(tm) Development Team



Joined: Mar 11, 2007
Posts: 2024
Location: North Carolina

PostPosted: Mon Aug 16, 2010 12:54 pm Reply with quote

line 18 does not have a closing }

Code:
if ($row2['radminsuper'] == 1 || $auth_user == 1) {

   if (!isset($op)) $op = 'reviews';

_________________
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Send e-mail Visit poster's website
rebelt







PostPosted: Mon Aug 16, 2010 1:56 pm Reply with quote

Thanks. Got rid of the error and advanced to a blank page. Shocked

How did you guys deal with the frustration side of working these things out?

I'm sure I didn't have this much grey hair when I started. Very Happy
 
nuken







PostPosted: Mon Aug 16, 2010 2:38 pm Reply with quote

None of your cases are a default. See if you can get anything by using modules.php?name=YourModulesName&op=list
 
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Mon Aug 16, 2010 3:39 pm Reply with quote

Do you have error reporting turned on? I bet you'll find something there that will help, like the missing $db from you global statements in those functions in admin/index.php
 
View user's profile Send private message Send e-mail
rebelt







PostPosted: Mon Aug 16, 2010 4:32 pm Reply with quote

I had a default after Palbin posted earlier.

Then Looking through the reviews module, none of the case had a default in admin/index.php so removed it. Rolling Eyes

Now I've put it back it works. Very Happy

Even without the $db.

Although I suppose I should go through putting it in.

Thanks guys.

Amazing how you can just look at somthing and know what's wrong.
worship
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> For Hire

View next topic
View previous topic
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 can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©