Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16

Thread: Max Points

  1. #1
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts

    Max Points

    I have a points system on my site. Using a database.
    I don't want users to be able to go over 550pts by clicking links. Wondering if I coded this right.


    $checkpoints = $userobj->GetTodayPoint($friend_id);
    if($checkpoints>=550)
    {
    echo "You have reached your adding limit for today. Please post bulletins for more points";
    exit();
    }

    where user_today_points in the database is self evident... is this proper way of saying if points greater than 550?
    Last edited by mrnightowl; 07-26-2007 at 05:17 AM.

  • #2
    Regular Coder zro@rtv's Avatar
    Join Date
    Feb 2005
    Location
    on the network
    Posts
    433
    Thanks
    0
    Thanked 1 Time in 1 Post
    that should work fine, is it not?
    http://www.w3schools.com/php/php_operators.asp
    ._-zro
    zro@redtv
    zro.redtv.org

    "If HTML and the Web made all the online documents look like one huge book, RDF, schema, and inference languages will make all the data in the world look like one huge database"
    -Tim Berners-Lee, Weaving the Web, 1999

  • #3
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by zro@rtv View Post
    that should work fine, is it not?
    http://www.w3schools.com/php/php_operators.asp
    It is working now thanks... but my problem is I guess with the function to get SUM of total points for the day from adding users... the method I posted there gets total points from the day but not just from adding users. here the new function I tried to make

    Code:
    function AddPoints($friend_id)
    	{
    		global $ado;
    		$add_point = 0;
    		$today = date('Y-m-d');
    		$sql = "SELECT SUM(points) AS total FROM tbl_user_points 
    				WHERE user_login_id='$friend_id' 
    				AND
    				added_date='$today'"; 
    				points_for='adduser'";
    		$res = $ado->execute($sql);
    		$row = $ado->fetch($res);
    		if($row['point'] > 0)
    			$add_point = $row['point'];
    		}
    This is the error I get from this
    Parse error: parse error, unexpected '=' in /home/content/e/a/l/ealaut/html/classes/user.class.php on line 567

    I just want from tbl_user_points under the points_for I just want to have it get points from adduser for today not from bulletin which is the other variable.
    Last edited by mrnightowl; 07-26-2007 at 06:42 AM.

  • #4
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    It would help if you said which line that was...
    PHP Code:
    added_date='$today'"; 
    points_for='adduser'"

    Check your double quotes, you are terminating your SQL statement to early.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #5
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Your right ... don't know how I missed that ... I loaded up my script and a database on godaddy using a free hosting credit I had from registering the domain. I did correct that but now getting another error. I am very new to all this but I dont mind staying up all night to research and try to fix these errors.
    My new error is:

    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '; points_for='adduser' at line 4

    Looking into that now. I dont see the problem but yeah... lol

  • #6
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    I'm assuming that adduser is suppose to be a PHP variable. Try preceding it with a $. Actually, you should post your updated code so that I can evaluate it.

    Code:
    		$sql = "SELECT SUM(points) AS total FROM tbl_user_points 
    				WHERE user_login_id='$friend_id' 
    				AND
    				added_date='$today'"; 
    				points_for='$adduser'";

    P.S. - You're on programmers hours now :P. I just came back from Kinkos and its nearly 4am .
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #7
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts
    adduser is a database value..... under the tbl_user_points I have .. added_date and points_for which can be adduser,bulletin, or vote

    what I want is for it to fetch on only adduser for todays date I don't want the total for bulletin or votes on todays date just the adduser

  • #8
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Here is another way I've tried to do it...

    Code:
    function AddPoints($friend_id)
    	{
    		global $ado;
    		$add_point = 0;
    		$today_point = 0;
    		$today = date('Y-m-d');
    		$sql = "SELECT SUM(points) AS point FROM tbl_user_points 
    				WHERE user_login_id='$friend_id' 
    				AND 
    				points_for='adduser'";
    		$res = $ado->execute($sql);
    		$row = $ado->fetch($res);
    		if($row['point'] > 0)
    			$add_point = $row['point'];
    		
    		
    		$sql = "SELECT SUM(points) AS point FROM tbl_user_points 
    				WHERE user_login_id='$friend_id' 
    				AND 
    				added_date='$today'";
    		$res = $ado->execute($sql);
    		$row = $ado->fetch($res);
    		if($row['point'] > 0)
    			$today_point = $row['point'];
    		$arr = array("add_point"=>$add_point,"today_point"=>$today_point);
    		return $arr;
    	}

  • #9
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Well you should be able to keep them both in the WHERE clause. I just noticed in the first example that you do not have a AND between the two conditions of the WHERE clause.

    Code:
    		$sql = "SELECT SUM(points) AS total FROM tbl_user_points 
    				WHERE user_login_id='$friend_id' 
    				AND
    				added_date='$today'
    				AND 
    				points_for='adduser'";
    When troubleshooting queries, its a good thing to test directly in the database environment. That way, you can bypass some additional oversights. Were you receiving an error with the last two seperate queries?
    Last edited by StupidRalph; 07-26-2007 at 10:40 AM. Reason: too many grammatical errors....only a few would've been okay :P
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #10
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by StupidRalph View Post
    Well you should be able to keep them both in the WHERE clause. I just noticed in the first example that you do not have a AND between the two conditions of the WHERE clause.

    Code:
    		$sql = "SELECT SUM(points) AS total FROM tbl_user_points 
    				WHERE user_login_id='$friend_id' 
    				AND
    				added_date='$today'
    				AND 
    				points_for='adduser'";
    When troubleshooting queries, its a good thing to test directly in the database environment. That way, you can bypass some additional oversights. Were you receiving an error with the last two seperate queries?


    AAAAAh YES... very good... works great thank you. Don't know if your still on but I did have another question. If you don't mind. Reason I'm doing all this is to prevent people from just being able to click away. One last thing I've been having a hard time figuring out is how to slow them down on clicking the links... I have this code:

    Code:
    <?PHP
    			//echo"$row_user[user_login_id]";
    			?>
    			
    			<a class="fade" href="adduser.php?addid=<?=$row_user['user_login_id']?>&act=<?=$_GET['action']?>" target="_blank"><img src="<?=$row_user['user_picture']?>" width="100" height="100" border="0"></a>
    			<BR><a href="adduser.php?addid=<?=$row_user['user_login_id']?>&act=<?=$_GET['action']?>" target="_blank">Add</a> | <a target="_blank" href="http://myspace.com/<?=$row_user['user_login_id']?>">View</a>
    Along with the other code to generate 25 links for them to click at a time... is there a php way to make them only be able to click a link every few seconds? or do I have to go with javascript or some other form to prevent them from clicking 10 or 20 links in a few seconds...

    Thanks again for the help on clearing up my syntax problem....

  • #11
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Everytime someone clicks a link, you can store the time in a session variable. When they click another link you just compare whats in the session variable with the current time. If not enough time has passed then don't allow them to get points. If you want this check to take place on the client side (in the browser) then you'll have to use javascript (or vbscript, but lets be realistic).

    Also, note that if you don't want them to CLICK the link then it'll have to be on the client-side (javascript). You'll have to write some type of function that basically does the same thing as described above except you would't use a session variable just a regular javascript variable. Also note, that if they're using javascript that they can simply turn off javascript and bypass this securtiy feature. One thing you can do is not make them hyperlinks, you can use javascript to activate them as hyperlinks. So if they have javascript turned off, it won't work anyway. :P

    Code:
    function hyperlink(link) {
    
    window.open(link,location=0,status=0,scrollbars=1,menubar=yes,resizeable=yes,width=400,height=400');
    } ..... <a href="#" onclick="javascript: hyperlink('http://myspace.com/<?=$row_user['user_login_id']');?>">View</a>
    Or something like that, I didn't test it, and I'm NO javascript person :P.
    Last edited by StupidRalph; 07-26-2007 at 11:16 AM.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #12
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Ok cool I would actually prefer it to be client side ... for the fact I am trying to reduce server load...
    so someting starting like this?

    Code:
    var timeStamp =
    function checkClick(lclick)
    var timeNow =
    where I could put a onclick="checkClick" in the <a href>
    Last edited by mrnightowl; 07-26-2007 at 11:11 AM.

  • #13
    Senior Coder
    Join Date
    Mar 2003
    Location
    Atlanta
    Posts
    1,037
    Thanks
    14
    Thanked 30 Times in 28 Posts
    Umm this is going to be the wrong forum to start this discussion but you can simply use javascripts Date() to get the time

    Code:
        var now = new Date()
        var hours = now.getHours()
        var minutes = now.getMinutes()
        var seconds = now.getSeconds()
    But as stated, I'm totally not the javascript person :P. I think you can actually use a timestamp as you've named one of your variables.
    Last edited by StupidRalph; 07-26-2007 at 11:23 AM.
    Most of my questions/posts are fairly straightforward and simple. I post long verbose messages in an attempt to be thorough.

  • #14
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Quote Originally Posted by StupidRalph View Post
    Everytime someone clicks a link, you can store the time in a session variable. When they click another link you just compare whats in the session variable with the current time. If not enough time has passed then don't allow them to get points. If you want this check to take place on the client side (in the browser) then you'll have to use javascript (or vbscript, but lets be realistic).

    Also, note that if you don't want them to CLICK the link then it'll have to be on the client-side (javascript). You'll have to write some type of function that basically does the same thing as described above except you would't use a session variable just a regular javascript variable. Also note, that if they're using javascript that they can simply turn off javascript and bypass this securtiy feature. One thing you can do is not make them hyperlinks, you can use javascript to activate them as hyperlinks. So if they have javascript turned off, it won't work anyway. :P

    Code:
    function hyperlink(link) {
    
    window.open(link,location=0,status=0,scrollbars=1,menubar=yes,resizeable=yes,width=400,height=400');
    } ..... <a href="#" onclick="javascript: hyperlink('http://myspace.com/<?=$row_user['user_login_id']');?>">View</a>
    Or something like that, I didn't test it, and I'm NO javascript person :P.
    Aaah ok yeah that would be a good idea...

    Code:
    var timeStamp = null;
    function checkClick(lclick){}
    var timeNow = new now.getMinutes() +":" + now.getSeconds()
    if(timeNow - timeStamp > 10 seconds || timeStamp == null){
    timeStamp = new now.getMinutes() +":" + now.getSeconds()
    }
    else
    {
    // clicked too fast
    }
    }
    Guess something along that line but I'm poor in that myself trying to take this all in... not sure on the time vars but I can take it to the javascript board...

  • #15
    New Coder
    Join Date
    Jul 2007
    Posts
    78
    Thanks
    6
    Thanked 2 Times in 2 Posts
    Well thank you very much again for all your help Ralph... Made my night/morning worth while knowing I'm getting somewhere.... Enjoy the rest of your week. Take care.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •