Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
rebelt
Worker
Worker



Joined: May 07, 2006
Posts: 172

PostPosted: Mon Sep 06, 2010 9:37 am Reply with quote

Edit:

Starting again with this. Please ignore.

_________________
I wish I knew what I was doing LOL

Last edited by rebelt on Mon Sep 06, 2010 2:35 pm; edited 1 time in total 
View user's profile Send private message Visit poster's website
Palbin
Site Admin



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

PostPosted: Mon Sep 06, 2010 9:57 am Reply with quote

What exactly is your question?

_________________
"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







PostPosted: Mon Sep 06, 2010 10:00 am Reply with quote

Sorry.

I'm getting the "Somehow you have got this far etc" error message but all the fields are filled in.
 
Guardian2003
Site Admin



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

PostPosted: Fri Sep 10, 2010 6:32 am Reply with quote

That usually happens if you fill out the fields once but try submitting it again. If you are installing, close the browser window (or clear your session cookies) and try again.
 
View user's profile Send private message Send e-mail
rebelt







PostPosted: Tue Sep 14, 2010 7:49 am Reply with quote

Thanks but that didn't work.

Could someone possibly look over the script please.
Code:
<?PHP

if ( !defined('MODULE_FILE') )
{
   die("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));

if (!defined('INDEX_FILE')) define('INDEX_FILE', true); // Set to FALSE to hide right blocks

###
### Main Page
###

function mainpage() {
   include ('header.php');

   $result = mysql_query("select match_id, home_team, away_team, home_score, away_score, cup, match_date from team_scores2 where status>0 order by match_date DESC");

   echo "<center><H2><B>Live Cup Result Listings</b></h2></center>";

   echo "<center><B>All results submitted through this system must be genuine match results only.</b><BR><BR><B></center>";

   echo "<BR><table width=100%>";

   $lastmatchdate="";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $cup, $match_date) = mysql_fetch_row($result))
{
   if ($match_date!=$lastmatchdate)
   {
      $matchdate = date("Y-m-d", strtotime($match_date));
      $displaymatchdate = date("d-m-Y", strtotime($match_date));
      echo "<tr><td colspan=4 align=center><font size=2><b><a href=\"modules.php?name=Cup_results&op=showdate&date=$matchdate\">Click here for matches played on $displaymatchdate</a></b></font size=2></td></tr>";
   }
   $lastmatchdate=$match_date;
}

   echo "</table>";

   livefooter();
   mysql_free_result($result);
   include ('footer.php');
}

###
### Show Date Listing
###

function showdate($matchdate) {
   include ('header.php');

   $result = mysql_query("select match_id, home_team, away_team, home_score, away_score, cup, match_date, status, comments from team_scores2 where status>0 AND match_date='$matchdate' order by match_date, cup");

   echo "<BR><center><table width=75% border=1 valign=top>";
   $lastcup="9";
   $lastmatchdate="";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $cup, $match_date, $status, $comments) = mysql_fetch_row($result))
{
   if ($match_date!=$lastmatchdate)
   {
      $matchdate = date("Y-m-d", strtotime($match_date));
      $displaymatchdate = date("d-m-Y", strtotime($match_date));
      echo "<tr><td colspan=4 align=center bgcolor=\"#B1CFED\"><h2><b>Games Played On $displaymatchdate</b></h2></td></tr>";
   }
   if ($cup!=$lastcup)
   {
      echo "<tr><td colspan=4 align=center bgcolor=\"#EEF4FC\"><font size=4><b>cup $cup</b></font size=4></td></tr>";
   }


   if ($status==1)
   {
      echo "<tr><td bgcolor=\"#ffffff\" align=right width=43%><font size=4><a href=\"modules.php?name=Cup_results&amp;op=teammatches&team=$home_team\">$home_team</a></font size=4></td><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$home_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$away_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=left width=43%><font size=4><a href=\"modules.php?name=Cup_results&amp;op=teammatches&team=$away_team\">$away_team</a></font size=4></td></tr>";
   }
   $thiscount=$thiscount+1;
   $lastcup=$cup;
   $lastmatchdate=$match_date;
}

   livefooter();
   mysql_free_result($result);
   include ('footer.php');
}

###
### Show All Team Match Scores By date
###

function teammatches($team) {
   include ('header.php');

   $result = mysql_query("select match_id, home_team, away_team, home_score, away_score, cup, match_date, status, comments from team_scores2 where status>0 AND (home_team='$team' or away_team='$team') order by match_date");

   echo "<BR><center><table width=90% border=1 valign=top>";
   echo "<tr><td colspan=5 align=center bgcolor=\"#B1CFED\"><h3>Games Played By $team This Season</h3></td></tr>";

while (list($match_id, $home_team, $away_team, $home_score, $away_score, $cup, $match_date, $status, $comments) = mysql_fetch_row($result))
{
   $matchdate = date("Y-m-d", strtotime($match_date));
   $displaymatchdate = date("d-m-Y", strtotime($match_date));
   echo "<tr><td bgcolor=\"#ffffff\" align=right width=20%><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=33%><font size=4><a href=\"modules.php?name=Cup_results&amp;op=teammatches&team=$home_team\">$home_team</a></font size=4></td><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$home_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$away_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=left width=33%><font size=4><a href=\"modules.php?name=Cup_results&amp;op=teammatches&team=$away_team\">$away_team</a></font size=4></td></tr>";
}
   echo "</table></center>";

   ### Graph Progress

   $result = mysql_query("select match_id, home_team, away_team, home_score, away_score, cup, match_date, status, comments from team_scores2 where status>0 AND (home_team='$team' or away_team='$team') order by match_date");

   echo "<BR><center><table width=90% border=1 valign=top>";
   echo "<tr><td colspan=3 align=center bgcolor=\"#B1CFED\"><h3>Progress This Season</h3></td></tr>";
   echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>Match Date</font size=4></td><td bgcolor=\"#ffffff\" align=right width=40%><font size=4>Games Against</font size=4></td><TD bgcolor=\"#ffffff\" align=left width=40%><font size=4>Games For</font size=4></td></tr>";


while (list($match_id, $home_team, $away_team, $home_score, $away_score, $cup, $match_date, $status, $comments) = mysql_fetch_row($result))
{
   $matchdate = date("Y-m-d", strtotime($match_date));
   $displaymatchdate = date("d-m-Y", strtotime($match_date));
   $homewidth=$home_score*18;
   $awaywidth=$away_score*18;
}
if ($team==$away_team)
{
   echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=40%>$home_score<img src=\"/images/reddot.jpg\" height=20 width=$homewidth></td><TD bgcolor=\"#ffffff\" align=left width=40%><img src=\"/images/greendot.jpg\" height=20 width=$awaywidth>$away_score</td></tr>";
}
else
{
   echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=40%>$away_score<img src=\"/images/reddot.jpg\" height=20 width=$awaywidth></td><TD bgcolor=\"#ffffff\" align=left width=40%><img src=\"/images/greendot.jpg\" height=20 width=$homewidth>$home_score</td></tr>";
}
{
   echo "</table></center>";

   livefooter();

   mysql_free_result($result);
   include ('footer.php');
}
}
###           
### Result Form
###           

function resultform($user) {
   include ('header.php');
   OpenTable();
   ### registered user or email address
   $user2 = base64_decode($user);
   $user2 = addslashes($user2);
   $user2 = explode(":", $user2);
   $username = "$user2[1]";

if (date("Y-m-d", strtotime("this sunday"))==date("Y-m-d", strtotime("today")))
{
   $lastsunday = date("Y-m-d", strtotime("today"));
   $displaylastsunday = date("d-m-Y", strtotime("today"));
}
else
{
   $lastsunday = date("Y-m-d", strtotime("last sunday"));
   $displaylastsunday = date("d-m-Y", strtotime("last sunday"));
}
if ($username=='')
{
   die ("<font size=4>You must be logged in to submit a result...</font size=4>");

}
   echo "<font size=4>Submit Cup Match Result. If 7-0, please indicate if a no show in the comments box.</font size=4>";

   echo "<FORM ACTION=\"modules.php?name=Cup_results\" METHOD=\"POST\" NAME=\"Result\">";

   echo "<B>Which Cup:</b></font><select name=\"which_cup\" size=\"1\">
      <option>Select A Cup</option>
      <option>Baxter</option>
      <option>Forresters</option>
      <option>Gifford</option>
      <option>MacAverne</option>
      <option>Workingmens</option>
      </select><BR>
      <b>Home Team:</b><input type=text NAME=\"home_team\"><br />
      <B>Home Score:</b><select name=\"home_score\" size=\"1\">
      <option>Select A Score</option>
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
      <option>5</option>
      <option>6</option>

      <option>7</option>
      </select><BR>
      <b>Away Team:</b><input type=text name=\"away_team\"><br />
      <B>Away Score:</b><select name=\"away_score\" size=\"1\">
      <option>Select A Score</option>
      <option>0</option>
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
      <option>5</option>
      <option>6</option>
      <option>7</option>
      </select><BR>
      <B>Date:</b> <input type=text NAME=\"matchdate\" value=\"$displaylastsunday\" disabled><BR>
      <B>Your Name:</b> <input type=text NAME=\"submitter\" size=30><BR>";
{
   echo "<B>User ID: </b> <input type=text NAME=\"email\" size=30 value=\"".$username."\" disabled> As a registered user your results are prevalidated<BR>";
}
echo  "
      <textarea name=\"comments\" cols=60 rows=5></textarea>
      <input type=hidden name=\"op\" value=\"submitted\">
      <input type=hidden name=\"away-team\">
      <input type=hidden NAME=\"matchdate\" value=\"$lastsunday\">
      <input type=hidden NAME=\"which_cup\" value=\"\">
      <input type=hidden name=\"home_team\">
      <BR clear=all><INPUT TYPE=\"submit\" value=\"Submit\">";

   echo "</form>";

   livefooter();
   CloseTable();
   include ('footer.php');
}

### Add Result To Database
### Add Result To Database
### Add Result To Database

function submittedresult($home_team, $away_team, $home_score, $away_score, $cup, $match_date, $submitter, $email, $comments, $user) {
   include ('header.php');

 
   ### registered user or email address
   $user2 = base64_decode($user);
   $user2 = addslashes($user2);
   $user2 = explode(":", $user2);
   $username = "$user2[1]";
if ($username!=''){$email=$username;}



   #$cup=substr($cup,22,1);

   ## Get date of next sunday
if (date("Y-m-d", strtotime("this sunday"))==date("Y-m-d", strtotime("today")))
{
   $lastsunday = date("Y-m-d", strtotime("today"));
}
else
{
   $lastsunday = date("Y-m-d", strtotime("last sunday"));
}
   $matchdate = date("Y-m-d", strtotime($match_date));
   $displaymatchdate = date("d-m-Y", strtotime($match_date));

   ##
   ## Make sure all fields are filled in
   ##
if ($home_team=='' or $away_team=='' or $home_score=='' or $away_score=='' or $cup=='' or $match_date=='' or $email=='')
{
   echo "Somehow you have got this far without filling in all the fields on the previous form. Please return to the previous page and fill in all the fields.";
   exit;
}

   # check to see if this result has been submitted twice

   $result = mysql_query("select COUNT(*) from team_scores2 where home_team='$home_team' AND away_team='$away_team' AND match_date='$match_date' AND cup='$cup' AND home_score='$home_score' AND away_score='$away_score' AND submitter='$submitter' AND email='$email'");
   $totalcount3=mysql_fetch_array($result);
   $alreadylogged= $totalcount3[0];

   if ($alreadylogged==0){
      $result=mysql_query("insert into team_scores2 values (NULL, '$home_team', '$away_team', $home_score, $away_score, '$cup', '$matchdate', '$submitter', 0, '$email', '$comments')");

      if (!$result) {
         die('Could not write record: ' . mysql_error());
      }
   }

   ### Read back in
   
   $result = mysql_query("select match_id from team_scores2 where home_team='$home_team' AND away_team='$away_team' AND match_date='$matchdate' AND cup='$cup' AND home_score='$home_score' AND away_score='$away_score' AND submitter='$submitter' AND email='$email' limit 1");

while (list($match_id) = mysql_fetch_row($result))
{

   $this_match=$match_id;
   $email2 = str_replace('.', ',', $email);
}

{
   ### Registered user. Send email and validate.

   ### Look up email address

   $result = mysql_query("select user_email from nuke_users where username='$email'");

   while (list($useremail) = mysql_fetch_row($result))
   {

      mail("$useremail", "Weston Pool League Result", "The following match result has been received and pre-validated.

cup: $cup
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $email
Email: $useremail
Comments: $comments

Thank you for your submission.

DO NOT DELETE THIS EMAIL. This is confirmation of receipt of your result and may be needed in cases of dispute.
", "From: [ Only registered users can see links on this board! Get registered or login! ]");
   }

   echo "<h2>Result Submission</h2>
   cup: $cup<BR>
   Home team: $home_team $home_score<BR>
   Away team: $away_team $away_score<BR>
   Match date: $displaymatchdate<BR>
   Submitted By: $email<BR>
   Email: $useremail<BR>
   Comments: $comments
   <BR><BR>";
   echo "<font size=4>As a pregistered site user your result has now been accepted, you can see it by <a href=\"modules.php?name=Cup_results&amp;op=showdate&date=$lastsunday\">clicking here</a>.<BR>.</font size=4>";

   ### Update result to live
   # delete where details are the same and != match_id

   mysql_query("delete from team_scores2 where (home_team='$home_team' AND away_team='$away_team' AND home_score='$home_score' AND away_score='$away_score' AND match_date='$match_date' AND match_id!='$this_match')");

   # make validated link live
   mysql_query("update team_scores2 set status='1' where match_id='$this_match'");

   #mail result to RebelT

   mail("webmaster@westonpoolleague.org.uk", "League Result $home_team v $away_team", "The following result has been submitted

   Cup: $cup
   Home team: $home_team $home_score
   Away team: $away_team $away_score
   Match date: $displaymatchdate
   Submitted By: $email
   Email: $useremail
   Comments: $comments", "From: $useremail");

}


{
   echo "<B>This result has already been submitted. Please check the <a href=\"modules.php?name=Cup_results&amp;op=showdate&date=$lastsunday\">real time results service</a>.<BR><BR>";
}

   livefooter();
   include ('footer.php');
}


###
### Make Live
###

function makelive_result($id, $validate)
{
   $email = str_replace(',', '.', $validate);

   # read match in
   $result = mysql_query("select home_team, away_team, home_score, away_score, match_date, email from team_scores2 where match_id='$id'");
   while (list($home_team, $away_team, $home_score, $away_score, $match_date, $thisemail) = mysql_fetch_row($result))
   {
      # delete where details are the same and != match_id
      if ($email==$thisemail){
         mysql_query("delete from team_scores2 where (home_team='$home_team' AND away_team='$away_team' AND home_score='$home_score' AND away_score='$away_score' AND match_date='$match_date' AND match_id!='$id')");    }
   }

   # make validated link live
   mysql_query("update team_scores2 set status='1' where match_id='$id' AND email='$email' AND status='0'");

   if (mysql_affected_rows()==0)
   {
      $result = mysql_query("select COUNT(*) from team_scores2 where match_id='$id'");
      $totalcount2=mysql_fetch_array($result);
      $totalcount= $totalcount2[0];

      # No such ID
      if ($totalcount==0)
      {

         dispmessage('nosuchmatchID', $id);
      }
      else
      {

         $result = mysql_query("select home_team, away_team, home_score, away_score, cup, match_date, submitter, email, status, comments from team_scores2 where match_id='$id'");

         while (list($home_team, $away_team, $home_score, $away_score, $cup, $match_date, $submitter, $thisemail, $status, $comments) = mysql_fetch_row($result))
         {
            # Already validated
            if ($status=='1'){dispmessage('alreadyvalidated', $id);}
            # SMS Entry
            if ($status=='3'){dispmessage('smssubmission', $id);}
            # Wrong email address
            if ($email!=$thisemail){dispmessage('wrongemail', $id);}
         }
      }
   }
   else
   {
      $result = mysql_query("select home_team, away_team, home_score, away_score, cup, match_date, submitter, email, comments from team_scores2 where match_id='$id'");
      while (list($home_team, $away_team, $home_score, $away_score, $cup, $match_date, $submitter, $email, $comments) = mysql_fetch_row($result))
      {
         $matchdate = date("Y-m-d", strtotime($match_date));
         $displaymatchdate = date("d-m-Y", strtotime($match_date));

         mail("webmaster@westonpoolleague.org.uk", "League Result $home_team v $away_team", "The following result has been verified.

cup: $cup
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $submitter
Email: $email
Comments: $comments", "From: [ Only registered users can see links on this board! Get registered or login! ]");

         dispmessage('authorised', $id);
      }
   }
}

###
### Errors and Confirmation
###

function dispmessage($messagetype, $id) {
   include ('header.php');

if (date("Y-m-d", strtotime("this sunday"))==date("Y-m-d", strtotime("today")))
{
   $lastsunday = date("Y-m-d", strtotime("today"));
}
else
{
   $lastsunday = date("Y-m-d", strtotime("last sunday"));
}

if ($messagetype=="authorised")
{
   echo "<h2><B>Result Validation</b></h2><BR><BR>";
   echo "Thank you, your result was successfully verified and has been added to the database. You can view this result on the <a href=\"modules.php?name=Cup_results&amp;op=showdate&date=$lastsunday\">real time results service by clicking here</a>.";
}
}
###
### Page Footer
###
function livefooter(){
   echo "<BR><BR><center><table width=90% border=1><tr><td align=center width=50%><a href=\"modules.php?name=Cup_results&amp;op=resultform\"><B>Add Result</b></a></td></table></center><BR><BR><BR><BR>";
}

###
### Main Entry
###
   
switch($_REQUEST['op']) {

   case "resultform":
      resultform($_REQUEST['user']);
      break;

   case "list":
      listresults();
      break;

   case "makelive":
      makelive_result($_REQUEST['id'], $_REQUEST['validate']);
      break;

   case "showdate":
      showdate($_REQUEST['date']);
      break;

   case "teammatches":
      teammatches($_REQUEST['team']);
      break;

   case "delete":
      delete_result($_REQUEST['id'], $_REQUEST['validate']);
      break;

   case "submitted":
      submittedresult($_REQUEST['hometeam'], $_REQUEST['awayteam'], $_REQUEST['home_score'], $_REQUEST['away_score'], $_REQUEST['cup'], $_REQUEST['match_date'], $_REQUEST['submitter'], $_REQUEST['email'], $_REQUEST['comments'], $_REQUEST['user']);
      break;
   
   default:
      mainpage();
      break;

}
?>

I know it's still got the old mysql_query functions but didn't think that affected much.
Looked here, in books and other places without success. Bang Head
Any advice will be welcome.
 
nuken
RavenNuke(tm) Development Team



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

PostPosted: Tue Sep 14, 2010 7:58 am Reply with quote

Have you turned on error reporting and if so, what errors/notices are you receiving when the form is submitted?

_________________
Tricked Out News 
View user's profile Send private message Send e-mail Visit poster's website
Guardian2003







PostPosted: Tue Sep 14, 2010 8:09 am Reply with quote

Since you have edited your initial post, which I think was about an installation problem, I now have no idea what you are talking about.

If you can give us a clue, such as your current RavenNuke (tm) version (if you are using RN), what errors you are seeing etc, this might help us diagnose the problem.

I don't see how that file on it's own, is ever going to work, or more specifically
Code:
$result = myql_query(....
is not going to work because mysql_query needs a database connection to run the query, which is then used to populate the $result variable.
In RN you would need to add a global statement to your functions for the database connection and add it to the query, so your first function mainpage() would need to start with something like
Code:


 function mainpage() {
global $db;
include_once 'header.php';

$result = $db->mysql_query("select match_id, home_team, away_team, home_score, away_score, cup, match_date from team_scores2 where status>0 order by match_date DESC");
.....
 
nuken







PostPosted: Tue Sep 14, 2010 8:13 am Reply with quote

Also, I don't see where cup is being populated in the form. I see which cup but not cup.
 
rebelt







PostPosted: Tue Sep 14, 2010 10:09 am Reply with quote

Quote:
I now have no idea what you are talking about.

Laughing Not surprised because I'm not sure I do either.
Using latest Ravenuke.
Changed cup to which-cup (which is what it should be) as the field is which_cup Rolling Eyes

I am getting the error above (Somehow you have got this far etc) from line 255.
Changed all
mysql_query to $db->sql_query
mysql_fetch_row to $db->sql_fetchrow
mysql_fetch_array to $db->sql_fetchrow
mysql_free_result to $db->sql_freeresult

Added global $db; to functions.

Amended file
Code:
<?PHP

if ( !defined('MODULE_FILE') )
{
   die("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));

if (!defined('INDEX_FILE')) define('INDEX_FILE', true); // Set to FALSE to hide right blocks

###
### Main Page
###

function mainpage() {
   global $db;
include_once 'header.php';

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

   echo "<center><H2><B>Live Cup Result Listings</b></h2></center>";

   echo "<center><B>All results submitted through this system must be genuine match results only.</b><BR><BR><B></center>";

   echo "<BR><table width=100%>";

   $lastmatchdate="";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $which_cup, $match_date) = $db->sql_fetchrow($result))
{
   if ($match_date!=$lastmatchdate)
   {
      $matchdate = date("Y-m-d", strtotime($match_date));
      $displaymatchdate = date("d-m-Y", strtotime($match_date));
      echo "<tr><td colspan=4 align=center><font size=2><b><a href=\"modules.php?name=Cup_results&op=showdate&date=$matchdate\">Click here for matches played on $displaymatchdate</a></b></font size=2></td></tr>";
   }
   $lastmatchdate=$match_date;
}

   echo "</table>";

   livefooter();
   $db->sql_freeresult($result);
   include_once('footer.php');
}

###
### Show Date Listing
###

function showdate($matchdate) {
   global $db;
include_once 'header.php';

   $result = $db->sql_query("select match_id, home_team, away_team, home_score, away_score, which_cup, match_date, status, comments from team_scores2 where status>0 AND match_date='$matchdate' order by match_date, which_cup");

   echo "<BR><center><table width=75% border=1 valign=top>";
   $lastmatchdate="";
while (list($match_id, $home_team, $away_team, $home_score, $away_score, $which_cup, $match_date, $status, $comments) = $db->sql_fetchrow($result))
{
   if ($match_date!=$lastmatchdate)
   {
      $matchdate = date("Y-m-d", strtotime($match_date));
      $displaymatchdate = date("d-m-Y", strtotime($match_date));
      echo "<tr><td colspan=4 align=center bgcolor=\"#B1CFED\"><h2><b>Games Played On $displaymatchdate</b></h2></td></tr>";
   }


   if ($status==1)
   {
      echo "<tr><td bgcolor=\"#ffffff\" align=right width=43%><font size=4><a href=\"modules.php?name=Cup_results&amp;op=teammatches&team=$home_team\">$home_team</a></font size=4></td><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$home_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$away_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=left width=43%><font size=4><a href=\"modules.php?name=Cup_results&amp;op=teammatches&team=$away_team\">$away_team</a></font size=4></td></tr>";
   }
   $thiscount=$thiscount+1;
   $lastmatchdate=$match_date;
}

   livefooter();
   $db->sql_freeresult($result);
   include_once('footer.php');
}

###
### Show All Team Match Scores By date
###

function teammatches($team) {
   global $db;
include_once 'header.php';

   $result = $db->sql_query("select match_id, home_team, away_team, home_score, away_score, which_cup, match_date, status, comments from team_scores2 where status>0 AND (home_team='$team' or away_team='$team') order by match_date");

   echo "<BR><center><table width=90% border=1 valign=top>";
   echo "<tr><td colspan=5 align=center bgcolor=\"#B1CFED\"><h3>Games Played By $team This Season</h3></td></tr>";

while (list($match_id, $home_team, $away_team, $home_score, $away_score, $which_cup, $match_date, $status, $comments) = $db->sql_fetchrow($result))
{
   $matchdate = date("Y-m-d", strtotime($match_date));
   $displaymatchdate = date("d-m-Y", strtotime($match_date));
   echo "<tr><td bgcolor=\"#ffffff\" align=right width=20%><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=33%><font size=4><a href=\"modules.php?name=Cup_results&amp;op=teammatches&team=$home_team\">$home_team</a></font size=4></td><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$home_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=center width=7%><font size=4>$away_score</font size=4></TD><TD bgcolor=\"#ffffff\" align=left width=33%><font size=4><a href=\"modules.php?name=Cup_results&amp;op=teammatches&team=$away_team\">$away_team</a></font size=4></td></tr>";
}
   echo "</table></center>";

   ### Graph Progress

   $result = $db->sql_query("select match_id, home_team, away_team, home_score, away_score, which_cup, match_date, status, comments from team_scores2 where status>0 AND (home_team='$team' or away_team='$team') order by match_date");

   echo "<BR><center><table width=90% border=1 valign=top>";
   echo "<tr><td colspan=3 align=center bgcolor=\"#B1CFED\"><h3>Progress This Season</h3></td></tr>";
   echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>Match Date</font size=4></td><td bgcolor=\"#ffffff\" align=right width=40%><font size=4>Games Against</font size=4></td><TD bgcolor=\"#ffffff\" align=left width=40%><font size=4>Games For</font size=4></td></tr>";


while (list($match_id, $home_team, $away_team, $home_score, $away_score, $which_cup, $match_date, $status, $comments) = $db->sql_fetchrow($result))
{
   $matchdate = date("Y-m-d", strtotime($match_date));
   $displaymatchdate = date("d-m-Y", strtotime($match_date));
   $homewidth=$home_score*18;
   $awaywidth=$away_score*18;
}
if ($team==$away_team)
{
   echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=40%>$home_score<img src=\"/images/reddot.jpg\" height=20 width=$homewidth></td><TD bgcolor=\"#ffffff\" align=left width=40%><img src=\"/images/greendot.jpg\" height=20 width=$awaywidth>$away_score</td></tr>";
}
else
{
   echo "<tr><td bgcolor=\"#ffffff\" align=right><font size=4>$displaymatchdate</font></td><td bgcolor=\"#ffffff\" align=right width=40%>$away_score<img src=\"/images/reddot.jpg\" height=20 width=$awaywidth></td><TD bgcolor=\"#ffffff\" align=left width=40%><img src=\"/images/greendot.jpg\" height=20 width=$homewidth>$home_score</td></tr>";
}
{
   echo "</table></center>";

   livefooter();

   $db->sql_freeresult($result);
   include_once('footer.php');
}
}
###           
### Result Form
###           

function resultform($user) {
   global $db;
include_once 'header.php';
   OpenTable();
   ### registered user or email address
   $user2 = base64_decode($user);
   $user2 = addslashes($user2);
   $user2 = explode(":", $user2);
   $username = "$user2[1]";

if (date("Y-m-d", strtotime("this sunday"))==date("Y-m-d", strtotime("today")))
{
   $lastsunday = date("Y-m-d", strtotime("today"));
   $displaylastsunday = date("d-m-Y", strtotime("today"));
}
else
{
   $lastsunday = date("Y-m-d", strtotime("last sunday"));
   $displaylastsunday = date("d-m-Y", strtotime("last sunday"));
}
if ($username=='')
{
   die ("<font size=4>You must be logged in to submit a result...</font size=4>");

}
   echo "<font size=4>Submit Cup Match Result. If 7-0, please indicate if a no show in the comments box.</font size=4>";

   echo "<FORM ACTION=\"modules.php?name=Cup_results\" METHOD=\"POST\" NAME=\"Result\">";

   echo "<B>Which Cup:</b></font><select name=\"which_cup\" size=\"1\">
      <option>Select A Cup</option>
      <option>Baxter</option>
      <option>Forresters</option>
      <option>Gifford</option>
      <option>MacAverne</option>
      <option>Workingmens</option>
      </select><BR>
      <b>Home Team:</b><input type=text NAME=\"home_team\"><br />
      <B>Home Score:</b><select name=\"home_score\" size=\"1\">
      <option>Select A Score</option>
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
      <option>5</option>
      <option>6</option>

      <option>7</option>
      </select><BR>
      <b>Away Team:</b><input type=text name=\"away_team\"><br />
      <B>Away Score:</b><select name=\"away_score\" size=\"1\">
      <option>Select A Score</option>
      <option>0</option>
      <option>1</option>
      <option>2</option>
      <option>3</option>
      <option>4</option>
      <option>5</option>
      <option>6</option>
      <option>7</option>
      </select><BR>
      <B>Date:</b> <input type=text NAME=\"matchdate\" value=\"$displaylastsunday\" disabled><BR>
      <B>Your Name:</b> <input type=text NAME=\"submitter\" size=30><BR>";
{
   echo "<B>User ID: </b> <input type=text NAME=\"email\" size=30 value=\"".$username."\" disabled> As a registered user your results are prevalidated<BR>";
}
echo  "
      <textarea name=\"comments\" cols=60 rows=5></textarea>
      <input type=hidden name=\"op\" value=\"submitted\">
      <input type=hidden name=\"away-team\">
      <input type=hidden NAME=\"matchdate\" value=\"$lastsunday\">
      <input type=hidden NAME=\"which_cup\" value=\"\">
      <input type=hidden name=\"home_team\">
      <BR clear=all><INPUT TYPE=\"submit\" value=\"Submit\">";

   echo "</form>";

   livefooter();
   CloseTable();
   include_once('footer.php');
}

### Add Result To Database
### Add Result To Database
### Add Result To Database

function submittedresult($home_team, $away_team, $home_score, $away_score, $which_cup, $match_date, $submitter, $email, $comments, $user) {
   global $db;
include_once 'header.php';

 
   ### registered user or email address
   $user2 = base64_decode($user);
   $user2 = addslashes($user2);
   $user2 = explode(":", $user2);
   $username = "$user2[1]";
if ($username!=''){$email=$username;}


   ## Get date of next sunday
if (date("Y-m-d", strtotime("this sunday"))==date("Y-m-d", strtotime("today")))
{
   $lastsunday = date("Y-m-d", strtotime("today"));
}
else
{
   $lastsunday = date("Y-m-d", strtotime("last sunday"));
}
   $matchdate = date("Y-m-d", strtotime($match_date));
   $displaymatchdate = date("d-m-Y", strtotime($match_date));

   ##
   ## Make sure all fields are filled in
   ##
if ($home_team=='' or $away_team=='' or $home_score=='' or $away_score=='' or $which_cup=='' or $match_date=='' or $email=='')
{
   echo "Somehow you have got this far without filling in all the fields on the previous form. Please return to the previous page and fill in all the fields.";
   exit;
}

   # check to see if this result has been submitted twice

   $result = $db->sql_query("select COUNT(*) from team_scores2 where home_team='$home_team' AND away_team='$away_team' AND match_date='$match_date' AND which_cup='$which_cup' AND home_score='$home_score' AND away_score='$away_score' AND submitter='$submitter' AND email='$email'");
   $totalcount3=$db->sql_fetchrow($result);
   $alreadylogged= $totalcount3[0];

   if ($alreadylogged==0){
      $result=$db->sql_query("insert into team_scores2 values (NULL, '$home_team', '$away_team', $home_score, $away_score, '$which_cup', '$matchdate', '$submitter', 0, '$email', '$comments')");

      if (!$result) {
         die('Could not write record: ' . mysql_error());
      }
   }

   ### Read back in
   
   $result = $db->sql_query("select match_id from team_scores2 where home_team='$home_team' AND away_team='$away_team' AND match_date='$matchdate' AND which_cup='$which_cup' AND home_score='$home_score' AND away_score='$away_score' AND submitter='$submitter' AND email='$email' limit 1");

while (list($match_id) = $db->sql_fetchrow($result))
{

   $this_match=$match_id;
   $email2 = str_replace('.', ',', $email);
}

{
   ### Registered user. Send email and validate.

   ### Look up email address

   $result = $db->sql_query("select user_email from nuke_users where username='$email'");

   while (list($useremail) = $db->sql_fetchrow($result))
   {

      mail("$useremail", "Weston Pool League Result", "The following match result has been received and pre-validated.

Cup: $which_cup
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $email
Email: $useremail
Comments: $comments

Thank you for your submission.

DO NOT DELETE THIS EMAIL. This is confirmation of receipt of your result and may be needed in cases of dispute.
", "From: [ Only registered users can see links on this board! Get registered or login! ]");
   }

   echo "<h2>Result Submission</h2>
   Cup: $which_cup<BR>
   Home team: $home_team $home_score<BR>
   Away team: $away_team $away_score<BR>
   Match date: $displaymatchdate<BR>
   Submitted By: $email<BR>
   Email: $useremail<BR>
   Comments: $comments
   <BR><BR>";
   echo "<font size=4>As a pregistered site user your result has now been accepted, you can see it by <a href=\"modules.php?name=Cup_results&amp;op=showdate&date=$lastsunday\">clicking here</a>.<BR>.</font size=4>";

   ### Update result to live
   # delete where details are the same and != match_id

   $db->sql_query("delete from team_scores2 where (home_team='$home_team' AND away_team='$away_team' AND home_score='$home_score' AND away_score='$away_score' AND match_date='$match_date' AND match_id!='$this_match')");

   # make validated link live
   $db->sql_query("update team_scores2 set status='1' where match_id='$this_match'");

   #mail result to RebelT

   mail("webmaster@westonpoolleague.org.uk", "League Result $home_team v $away_team", "The following result has been submitted

   Cup: $which_cup
   Home team: $home_team $home_score
   Away team: $away_team $away_score
   Match date: $displaymatchdate
   Submitted By: $email
   Email: $useremail
   Comments: $comments", "From: $useremail");

}


{
   echo "<B>This result has already been submitted. Please check the <a href=\"modules.php?name=Cup_results&amp;op=showdate&date=$lastsunday\">real time results service</a>.<BR><BR>";
}

livefooter();
include_once('footer.php');
}


###
### Make Live
###

function makelive_result($id, $validate)
{
   $email = str_replace(',', '.', $validate);

   # read match in
   $result = $db->sql_query("select home_team, away_team, home_score, away_score, match_date, email from team_scores2 where match_id='$id'");
   while (list($home_team, $away_team, $home_score, $away_score, $match_date, $thisemail) = $db->sql_fetchrow($result))
   {
      # delete where details are the same and != match_id
      if ($email==$thisemail){
         $db->sql_query("delete from team_scores2 where (home_team='$home_team' AND away_team='$away_team' AND home_score='$home_score' AND away_score='$away_score' AND match_date='$match_date' AND match_id!='$id')");    }
   }

   # make validated link live
   $db->sql_query("update team_scores2 set status='1' where match_id='$id' AND email='$email' AND status='0'");

   if (mysql_affected_rows()==0)
   {
      $result = $db->sql_query("select COUNT(*) from team_scores2 where match_id='$id'");
      $totalcount2=$db->sql_fetchrow($result);
      $totalcount= $totalcount2[0];

      # No such ID
      if ($totalcount==0)
      {

         dispmessage('nosuchmatchID', $id);
      }
      else
      {

         $result = $db->sql_query("select home_team, away_team, home_score, away_score, which_cup, match_date, submitter, email, status, comments from team_scores2 where match_id='$id'");

         while (list($home_team, $away_team, $home_score, $away_score, $which_cup, $match_date, $submitter, $thisemail, $status, $comments) = $db->sql_fetchrow($result))
         {
            # Already validated
            if ($status=='1'){dispmessage('alreadyvalidated', $id);}
            # SMS Entry
            if ($status=='3'){dispmessage('smssubmission', $id);}
            # Wrong email address
            if ($email!=$thisemail){dispmessage('wrongemail', $id);}
         }
      }
   }
   else
   {
      $result = $db->sql_query("select home_team, away_team, home_score, away_score, which_cup, match_date, submitter, email, comments from team_scores2 where match_id='$id'");
      while (list($home_team, $away_team, $home_score, $away_score, $which_cup, $match_date, $submitter, $email, $comments) = $db->sql_fetchrow($result))
      {
         $matchdate = date("Y-m-d", strtotime($match_date));
         $displaymatchdate = date("d-m-Y", strtotime($match_date));

         mail("webmaster@westonpoolleague.org.uk", "League Result $home_team v $away_team", "The following result has been verified.

Cup: $which_cup
Home team: $home_team $home_score
Away team: $away_team $away_score
Match date: $displaymatchdate
Submitted By: $submitter
Email: $email
Comments: $comments", "From: [ Only registered users can see links on this board! Get registered or login! ]");

         dispmessage('authorised', $id);
      }
   }
}

###
### Errors and Confirmation
###

function dispmessage($messagetype, $id) {
   global $db;
include_once 'header.php';

if (date("Y-m-d", strtotime("this sunday"))==date("Y-m-d", strtotime("today")))
{
   $lastsunday = date("Y-m-d", strtotime("today"));
}
else
{
   $lastsunday = date("Y-m-d", strtotime("last sunday"));
}

if ($messagetype=="authorised")
{
   echo "<h2><B>Result Validation</b></h2><BR><BR>";
   echo "Thank you, your result was successfully verified and has been added to the database. You can view this result on the <a href=\"modules.php?name=Cup_results&amp;op=showdate&date=$lastsunday\">real time results service by clicking here</a>.";
}
include_once('footer.php');
}
###
### Page Footer
###
function livefooter(){
   echo "<BR><BR><center><table width=90% border=1><tr><td align=center width=50%><a href=\"modules.php?name=Cup_results&amp;op=resultform\"><B>Add Result</b></a></td></table></center><BR><BR><BR><BR>";
}

###
### Main Entry
###
   
switch($_REQUEST['op']) {

   case "resultform":
      resultform($_REQUEST['user']);
      break;

   case "list":
      listresults();
      break;

   case "makelive":
      makelive_result($_REQUEST['id'], $_REQUEST['validate']);
      break;

   case "showdate":
      showdate($_REQUEST['date']);
      break;

   case "teammatches":
      teammatches($_REQUEST['team']);
      break;

   case "delete":
      delete_result($_REQUEST['id'], $_REQUEST['validate']);
      break;

   case "submitted":
      submittedresult($_REQUEST['hometeam'], $_REQUEST['awayteam'], $_REQUEST['home_score'], $_REQUEST['away_score'], $_REQUEST['which_cup'], $_REQUEST['match_date'], $_REQUEST['submitter'], $_REQUEST['email'], $_REQUEST['comments'], $_REQUEST['user']);
      break;
   
   default:
      mainpage();
      break;

}
?>

Hopefully you have more of an idea than I do Very Happy
 
nuken







PostPosted: Tue Sep 14, 2010 10:20 am Reply with quote

So the database is storing the cup as which_cup correct?
 
Palbin







PostPosted: Tue Sep 14, 2010 10:42 am Reply with quote

Your problem is with this line of code. Your first two variable names are not right.

Code:


      submittedresult($_REQUEST['hometeam'], $_REQUEST['awayteam'], $_REQUEST['home_score'], $_REQUEST['away_score'], $_REQUEST['cup'], $_REQUEST['match_date'], $_REQUEST['submitter'], $_REQUEST['email'], $_REQUEST['comments'], $_REQUEST['user']);
 
rebelt







PostPosted: Tue Sep 14, 2010 12:00 pm Reply with quote

Quote:
So the database is storing the cup as which_cup correct?

Yes. Here's the table
Code:
CREATE TABLE IF NOT EXISTS `team_scores2` (

  `match_id` int(10) NOT NULL auto_increment,
  `home_team` varchar(50) default NULL,
  `away_team` varchar(50) default NULL,
  `home_score` tinyint(2) NOT NULL default '0',
  `away_score` tinyint(2) NOT NULL default '0',
  `cup-match` varchar(50) default NULL,
  `match_date` datetime default NULL,
  `submitter` varchar(50) default NULL,
  `status` tinyint(2) NOT NULL default '0',
  `email` varchar(50) default NULL,
  `comments` text,
  PRIMARY KEY  (`match_id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=342 ;

Quote:
Your first two variable names are not right.

Spotted that juust after I posted. Now home_team and away_team.

Still getting the somehow message.
Off out now for a pool comp so will be away for a bit.
 
Palbin







PostPosted: Tue Sep 14, 2010 1:55 pm Reply with quote

rebelt, within the "somehow" message echo out all the variables and see which ones are actually blank. Then you will have a frame of reference on what to look at.
 
rebelt







PostPosted: Wed Sep 15, 2010 3:27 pm Reply with quote

Does that mean change to

echo $home_team
echo $away_team

etc

Instead of the if ($home_team=='' or $away_team=='' ?

Sorry but not sure what you mean.
 
nuken







PostPosted: Wed Sep 15, 2010 4:25 pm Reply with quote

Code:
submittedresult($_REQUEST['home_team'], $_REQUEST['away_team']
 
Palbin







PostPosted: Wed Sep 15, 2010 6:03 pm Reply with quote

rebelt, no leave the IF statement as is. After the error is echoed do the same to all of the variables. I'm on my phone so I can not give an example.
 
rebelt







PostPosted: Sun Sep 19, 2010 2:46 am Reply with quote

Result as follows.
Which Cup Blank
Home Team Blank
Home score visible
Away Team Visible
Away Score Visible
Date displays 1970-01-01
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

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 ©