1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Function not always working

Discussion in 'PHP' started by bscdesign.com, Dec 29, 2008.

  1. #1
    I have a traffic trading script I made and I have a function to randomly select a trade partners ID from all my active partners that have credits remaining. If there is none then the content is hosted and the user is not sent away and I record that hit as a "Hard Play".

    The problem I am having is I have a site that has 700-800 credits and it's ID should be returned more than it is. One of the pages that is set to send users to him is getting no partner ID returned and results in a Hard Play and loss of trade.

    Here is the code.

    function plug_redirect($base_url,$gameid,$links_credit_limit){
    
            $sql_query = "SELECT links.linkstatus, links.websiteid, links.credits,
    		trade_plugs.gameid,
    		trade_plugs.linkid,
    		trade_plugs.gamelink
    		FROM links, trade_plugs
    		WHERE links.linkstatus = 1
    		AND links.credits > 0
    		AND trade_plugs.gameid = '$gameid'
    		AND trade_plugs.gamelink != ''
    		AND trade_plugs.linkid=links.websiteid
    		ORDER BY rand() LIMIT 1";
            $result = mysql_query($sql_query) or die(mysql_error());
            if(mysql_num_rows($result)) {
    			//output as long as there are still available fields
    			while($row = mysql_fetch_array($result)) {
    				$linkid = $row['websiteid'];
            	}
            } else {
    			$linkid = "";
    		}
    
        return $linkid;
    
    }
    PHP:
    The problem has nothing to do with the trade partner because this is happening to many other pages and partners on my site also. When I run that query in phpMyAdmin it always shows someone but it isn't always doing it on the site.

    Does anyone know what is causing this or how to fix it?
     
    bscdesign.com, Dec 29, 2008 IP
  2. bscdesign.com

    bscdesign.com Active Member

    Messages:
    681
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Sorry to bump but it is extremely important I get this fixed.
     
    bscdesign.com, Dec 30, 2008 IP