Remove points from SQL when page is viewed.

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   re: Remove points from SQL when page is viewed.
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 43
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 
Well I know the bottom will not work. Just a quick glance of the above without hard study.

I don't think $points can be included as a global. I will have a closer look at it a little later today.



Back to top Reply with quote
#2   re: Remove points from SQL when page is viewed.
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 43
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 
You should remove some of the globals not needed and combine the two you have so that its only one set.

I did the following just kinda stabbing in the dark, but it should work.

$points = $userinfo['points'];
$username = $userinfo['username'];
$db->sql_query("UPDATE ".$prefix."_users SET points = '$points-1000' WHERE username = '$username'");



Back to top Reply with quote
#3   re: Remove points from SQL when page is viewed.
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 43
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 
Here is kinda what I was thining. This is just the php part. Be sure to backup if you have part of it working already.

<?php
/************************************************************************/
/*                                                                      */
/* Copyright (c) 2001-2002 by CrossWalkCentral                          */
/* http://www.crosswalkcentral.net                                      */
/*                                                                      */
/* CrossWalkCentral                                                     */
/* You Web Hosting Community!                                           */
/*                                                                      */
/* Let us customize this script for you.                                */
/*                                                                      */
/* Please let us know what you think of the Support Ticket System     */
/* at http://www.crosswalkcentral.net/modules.php?name=Forum            */
/*                           */
/* This program is free software.               */
/*                            */
/* DOWNLOAD SUPPORT TICKET SYSTEM PRO FOR 20USD AT         */
/*         HTTP://WWW.CROSSWALKCENTRAL.NET         */
/*                           */
/************************************************************************/

if (!eregi("modules.php", $PHP_SELF)) {
    die ("You can't access this file directly...");
}

include("header.php");
include("config.php");
//CUSTOM ACCESS BY POINTS - MJ HUFFORD - [ Register or login to view links on this board. ]
global $userinfo, $user, $db, $cookie, $prefix, $anonymous, $dbi, $user_prefix, $stop, $module_name, $redirect, $mode, $t, $f, $admin, $nukeurl, $startdate;
customized_access_points($userinfo['points'], 1000);  //WHERE 1000 = MIN POINTS TO ACCESS MODULE
$points = $userinfo['points'];
$username = $userinfo['username'];
$db->sql_query("UPDATE ".$prefix."_users SET points = '$points-1000' WHERE username = '$username'");
//$content = "";  <--This should only be used for a block!
getusrinfo($user);
cookiedecode( $user );
$ip = getenv( "REMOTE_ADDR" );
$username = $cookie[1];
if ( !isset( $username ) )
{
   $username = "$ip";
   $guest = 1;
}



?>



Back to top Reply with quote
#4   re: Remove points from SQL when page is viewed.
mjhufford
CZ Active Member
 Codezwiz Site Donator
mjhufford has been a member for over 20 year's 20 Year Member
usa.gif arkansas.gif
Occupation: IT Industry
Age: 47
Gender: Male
Fav. Sports Team: Da Bears.
Website:
Status: Offline
Joined: Jul 01, 2004
0.04 posts per day
Posts: 288
Points: 15,094
  MSN Messenger 
Try something like this:



//ESTABLISH GLOBALS
global $db, $cookie;

//GET USERNAME
$username = $cookie[1];

//UPDATE SQL
$db->sql_query("UPDATE ".$prefix."_users SET points = points - 1000 WHERE username = '".$username."'");


Hope this helps.



_________________
"The pursuit of easy things makes men weak."
-David O. McKay
Back to top Reply with quote
#5   re: Remove points from SQL when page is viewed.
ADF-Sniper
CZ Newbie
 Codezwiz Site Donator
ADF-Sniper has been a member for over 19 year's 19 Year Member
australia.gif
Age: 45
Gender: Male
Website:
Status: Offline
Joined: Jun 30, 2005
0.00 posts per day
Posts: 8
Points: 600
   
Iv been hacking away at this for ages... somethings not right..

I have my doubts about "$points-1000" and also I dont think $username is declaired.

Also I would think the points should be calculated first in php then updated to sql.

OPPS... Didnt see the post above.

EDIT: SOLVED THANK YOU BOTH VERY MUCH. I hope this also comes in handy for others icon_biggrin.gif



Back to top Reply with quote
#6   
mjhufford
CZ Active Member
 Codezwiz Site Donator
mjhufford has been a member for over 20 year's 20 Year Member
usa.gif arkansas.gif
Occupation: IT Industry
Age: 47
Gender: Male
Fav. Sports Team: Da Bears.
Website:
Status: Offline
Joined: Jul 01, 2004
0.04 posts per day
Posts: 288
Points: 15,094
  MSN Messenger 
Kewl...glad to help! icon_smile.gif




_________________
"The pursuit of easy things makes men weak."
-David O. McKay
Back to top Reply with quote
#7   re: Remove points from SQL when page is viewed.
floppydrivez
CZ Addict
 Codezwiz Site Donator
floppydrivez has been a member for over 18 year's 18 Year Member
usa.gif mississippi.gif
Occupation: graphic design
Age: 43
Gender: Male
Website:
Status: Offline
Joined: Feb 26, 2006
0.08 posts per day
Posts: 518
Points: 4,848
AIM Address Yahoo Messenger MSN Messenger 
mjhufford is always stealing my glory. icon_biggrin.gif Good to hear you got it all worked out sniper.

EDIT: what is the final code?



Back to top Reply with quote
#8   re: Remove points from SQL when page is viewed.
ADF-Sniper
CZ Newbie
 Codezwiz Site Donator
ADF-Sniper has been a member for over 19 year's 19 Year Member
australia.gif
Age: 45
Gender: Male
Website:
Status: Offline
Joined: Jun 30, 2005
0.00 posts per day
Posts: 8
Points: 600
   
You both did well... All I have to do now is get the submission form to shutdown a server and start it up again icon_biggrin.gif

EDIT: Final Code


if (!eregi("modules.php", $PHP_SELF)) {
    die ("You can't access this file directly...");
}

include("header.php");
include("config.php");
//CUSTOM ACCESS BY POINTS - MJ HUFFORD - [ Register or login to view links on this board. ]
global $userinfo, $user, $db, $cookie, $prefix, $anonymous, $dbi, $user_prefix, $stop, $module_name, $redirect, $mode, $t, $f, $admin, $nukeurl, $startdate;
customized_access_points($userinfo['points'], 1000);  //WHERE 1000 = MIN POINTS TO ACCESS MODULE
$points = $userinfo['points'];
$username = $userinfo['username'];


//ESTABLISH GLOBALS
global $db, $cookie;

//GET USERNAME
$username = $cookie[1];

//UPDATE SQL
$db->sql_query("UPDATE ".$prefix."_users SET points = points - 1000 WHERE username = '".$username."'");


getusrinfo($user);
cookiedecode( $user );
$ip = getenv( "REMOTE_ADDR" );
$username = $cookie[1];
if ( !isset( $username ) )
{
   $username = "$ip";
   $guest = 1;
}



?>



Checks to see if a user has 1000 Points, If not then brings back a error, if user has over 1000 points. then 1000 points taken from them.


Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

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 cannot download files in this forum