Problems with an Visitor Exchange Script

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
smsindex
Forum Newbie
Posts: 3
Joined: Thu Sep 26, 2002 6:44 am

Problems with an Visitor Exchange Script

Post by smsindex »

I own a Visitor Exchange Script, but it always shows only the same page.

Code: Select all

function viewpage()
{
        global $userid, $showup_frequency, $points_hit, $points_view, $showup_time, $url_default, $points_referer_view, $points_referer_jackpot_views, $points_referer_jackpot_points;
        if($userid)
        {
                $query="SELECT recently, refererid, views FROM accounts WHERE id='$userid';";
                $result=mysql_query($query);
                if($result)
                {
                        $result = @mysql_fetch_array($result);
                        $recently=split(' ', $resultїrecently]);
                        $refererid=$resultїrefererid];
                        $views=$resultїviews];
                        if($points_referer_jackpot_views && $points_referer_jackpot_points && $views+1==$points_referer_jackpot_views){
                                $query="UPDATE accounts SET points=points+$points_referer_jackpot_points WHERE id='$refererid';";
                                mysql_query($query);
                        }
                }
        }

        $query = "SELECT id, url FROM accounts WHERE  showup='1' AND id!='$userid' AND points>=$points_hit AND savepoints='0'";

        for($i=0; $i<count($recently) && $i<$showup_frequency; $i++)
        &#123;
                $query .= " AND id!='$recently&#1111;$i]'";
                $recentlies&#1111;]=$recently&#1111;$i];
        &#125;
        $query .= ' ORDER BY points DESC';
        $result=mysql_query($query);
        $result=@mysql_fetch_array($result);
        if($result&#1111;id] && $result&#1111;url])
        &#123;
                $query="UPDATE accounts SET hits=hits+1, points=points-$points_hit WHERE id='".$result&#1111;id]."';";
                mysql_query($query);
                $recently=implode(" ", $recentlies);
                $recently=$result&#1111;id]." ".$recently;
                $query="UPDATE accounts SET views=views+1, points=points+$points_view, recently='$recently', lastview='".time()."' WHERE id='$userid' AND lastview<='".time().-$showup_time."';";
                mysql_query($query);
                if($refererid)
                &#123;
                        $query="UPDATE accounts SET points=points+".$points_view*$points_referer_view." WHERE id='$refererid';";
                        mysql_query($query);
                &#125;
        &#125;else&#123;
                $result&#1111;url]=$url_default;
                $query="UPDATE accounts SET views=views+1, points=points+1, lastview='".time()."' WHERE id='$userid' AND lastview<='".time().-$showup_time."';";
                mysql_query($query);
                if($refererid)
                &#123;
                        $query="UPDATE accounts SET points=points+".(1)*$points_referer_view." WHERE id='$refererid';";
                        mysql_query($query);
                &#125;
        &#125;
        return array(
                url=>$result&#1111;url],
                id=>$result&#1111;id]
        );
&#125;
Coco
Forum Contributor
Posts: 339
Joined: Sat Sep 07, 2002 5:28 am
Location: Leeds, UK
Contact:

Post by Coco »

try escaping all the (") that are within your queries...
(insert \ before each one, not even sure if you need most of them anyhow)
ie.$query="UPDATE accounts SET views=views+1, points=points+1, lastview='".time()."' WHERE id='$userid' AND lastview<='".time().-$showup_time."';";


also your sql queries shouldnt have a ; to end them, end the php line but not the query so you should end up with:

$query="UPDATE accounts SET views=views+1, points=points+1, lastview='\".time().\"' WHERE id='$userid' AND lastview<='\".time().-$showup_time.\"'";

as to that helping much i dunno... sometimes the smallest error kills everything
smsindex
Forum Newbie
Posts: 3
Joined: Thu Sep 26, 2002 6:44 am

no

Post by smsindex »

It has the same effect.

I think it is an programming error. I buied this script from http://www.gooof.com (German)
and the programmer did not answer any email. I think I have to inform my Lawyer.
But you know, i have users on my exchange and i need to repair the script as soon as possible.

:?
Post Reply