Jump to content

TEENFRONT

Members
  • Posts

    338
  • Joined

  • Last visited

    Never

Posts posted by TEENFRONT

  1. Hey all,

     

    Hoping this is a quick fix.. i have a little search system that searches player nicknames.. it works fine except when it run into a "#" character in the url.. it just for some reason totally doesnt recgonise anything.

     

    When searching for this player "[Ram] Drummer Sam #1"  i urlencode it.

     

    http://www....co.uk/search_players.php?type=usernick&value=[Ram]+Drummer+Sam+#1&submit=Find

     

    doesnt work.. it misses off the #1 and only search for "[Ram] Drummer Sam " ...

     

    Why is it not seeing the "#1" ?

     

    more info

     

    im usuing a simple $_GET['value']; in my code and using a  LIKE '%$value%'  in my search query.

     

    Cheers guys !

  2. Hey

     

    Im just writing an additon to my invoicing system that returns all the piad invoices for the last tax year. I have a "paid" colum for my invoices which has data like, 01/01/2010 etc.

     

    my sql query is like this

     

    SELECT * FROM invoices WHERE paid LIKE '%/04/2009' AND paid LIKE '%/05/2009' AND paid LIKE '%/06/2009' ........ AND paid LIKE '%/01/2010' AND paid LIKE '%/02/2010'
    

     

    etc, basically covering everything from 04/2009 to 03/2010 .. but iv got 12 AND LIKE bits in my querry which seems abit overkill, any easier/faster way?

     

    Cheers!

  3. Hi

     

    I have my own custom advert manager. It basically rotates through and displays the tags of my advertising partners, who all have their own stats/earnings sites which I have to check daily.

     

    Is it possible, and where do I start, with like getting my server to login to these stats sites daily and pulling the impressions, revenue, cpm, etc from the pages?

     

    I know il have to do a bit of custom work once I'm actually on the stats page to find and grab the stats but how do I get there in the first place?

     

    I need my script to go to a URL, enter my login details, submit a form then grab the stats.

     

    Is it even possible? Any pointers?

     

    Cheers!!

  4. Ah man so simple lolol. Thank you very much.

     

    just tested and it works. Great stuff.

     

    Quick addition if i may.

     

    it still returns "10"  if i pass it the annoying blank space character "
"  ... which obviosuly is correct, but how do i just get it to not show anything if this is found in the string? or remove the entire "
"

     

    so if the string was " hello everybody 
 
 
 
 hello again" .. how would i get it to just return "hello everybody hell again" instead of "hellow everybody 10 10 10 10 hello again" ?

     

    Many thanks!

     

     

  5. Hey All,

     

    Just in need of some regex help.  i have a chat system, in which i want to clean the string before outputting it to the browser. Its been working but recently people have started flooding the chat with "blank messages" using special characters and/or things like this

     

    "
"  which when copied a pasted into the chat box a few times will flood the chat with a blank message.

     

    Iv just tried adding something in to stop this from happening am i think im halfway there. i have this

     

    $str = preg_replace("/[^a-z\d.,-@?*()_]/i",'',$str);
    

     

    when i do this

     

    $str = "
";
    $str = preg_replace("/[^a-z\d.,-@?*()_]/i",'',$str);
    

     

    It returns this

     

    10;
    

     

    most concerning of the above is that it allows ; although i dont say its an allowed character???

     

    so its only cleaning half of it.

     

    Basically, i only ever want to allow these characters.

     

    a-Z  (upper and lower)

    0-9

    .,@()!*-_

     

    How would i apply the above to a propper regex? or does anyone else have anything to clean input for chat systems and only allow the basic characters.

     

    Many thanks!

  6. works perfect! thanks so much mate!

     

    i have to dash out quickly but im guessing it i wanted to replace the "5" with a field that had other set numbers in, id just literally do

     

    SELECT * FROM `links` WHERE (`out` - `in`) <= `margin`
    

     

    ?

     

     

  7. Hey all

     

    Quick help required, probly really easy... Im doing a traffic exchange system for one of my sites and i need to select partners urls that have less "out" hits than they do "in" hits. I track hits elsewhere. The main issue is i want to do the selecting "within" 5 hits.

     

    So if site 1 has 15 in and 16 out, i still want to send another hit to this site, as its within "5".

    if site 2 has 20 hits in and 24 hits out, this is ok.

    if site 3 has 20 hits in and 26 hits out, this is not ok (because in is over 5 from out) and doesnt want selecting.

     

     

    The code i have at the moment just selects sites that have a less out than in value.

     

    $sql = "SELECT * FROM links WHERE `out` < `in` LIMIT 1";
    

     

    So thats too simple, i want to still select sites that out is within 5 more of in.

     

    More than confused.

  8. Hello,

     

    Just a quick one

     

    Whats quickest? my table has about 30 columns, and i only need 2-3 columns in my results, is selecting everything (*) quicker than just selecting 2-3 colums? 1-2 of the colums are indexed. I own and large site so little things like this might help with our serverload and memory usage.

     

    Cheers!

  9. Hey thanks for the advice.

     

    That last query you posted, iv never actually seen a query like that lol, could you explain what it's doing? Left join and inner join etc?

     

    If I was going to select all awaiting players I would have just done this

     

    select * from awaiting where team_id=$teamid

     

    what the difference between that and the complicated looking query that you just posted with joins etc?

     

    Cheers!

  10. Hey all,

     

    I'm trying to improve the speed of my database queries and I want to put some players IDs in a single column and seperate them by a comma.

     

    So inside my colum "awaiting" I want it to be like 123,356,8678,9799 etc.

     

    What's the fastest way or best way to add new IDs to this column and remove them.

     

    Basically when a player joins a team they go into awaiting, then when they get approved they get removed from awaiting and added into joined with the same comma seperated IDs

  11. Thanks for the reply..

     

    My dates are saved like this ...    "20100301213154587988"  .. iv never actually been able to figure out what format that is, and iv had to use the convert_timestamp function that came with the developers code.

     

    Do you know what this format is ? 20100301213154587988 ? and if so, how would i calculate 120 less than 20100301213154587988 ?

     

    Much appreciated! :)

  12. Hey all,

     

    Just  a quickie, basically, every week i run a cron job that removes players from the database who havent logged into our site for 4months. This is to keep the database trim and onl with active users.

     

    Basically this script currently loops through each player and "if play hasnt logged in for 4months" it runs a delete query. We have some 45,000 player records in our database.

     

    Im just thinking about it, and would it be faster, better, to first query the database and put all the usernames in an array that hasnt logged in for 4months, THEN run 1 single delete query?

     

    If so how would i do this? as i dont calculate the date logged in untill we get to the loop of the first query..

     

    My current code is like this... 

     

    
    function convert_timestamp($timestamp, $format) {
    ereg("([0-9]{4})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})([0-9]{2})", $timestamp, $regs);
    $new_timestamp = mktime($regs[4],$regs[5],$regs[6],$regs[2],$regs[3],$regs[1]);
    $date = date($format, $new_timestamp);
    return $date;
    }
    
    $result = mysql_query("select last_session_start, useremail, usernick from gamezer_users_1 WHERE userstatus=1 AND last_session_start !=0");
    
    while($r=mysql_fetch_array($result))
    { 
    $last_session_start = $r["last_session_start"];
    $timestamp = $last_session_start;
    $registered = convert_timestamp($timestamp, "d.m.Y");
    $start = $registered;
    $end = date('d.m.Y');
    
    $difference = (strtotime($end)-strtotime($start));
    
    $days = $difference/24; //hours in one day
    $days = $days/60; //minutes in one hour
    $days = $days/60; //seconds in one minute
    $days = ceil($days); //rounding up
    
    if($days >= 120) {
    $useremail = $r["useremail"];
    
    mail($to, $subject, $message, $headers);
    mysql_query("DELETE FROM gamezer_users_1 WHERE useremail='$useremail'") or die(mysql_error()); 
    }
    
    }
    

     

     

    How would i optimize the above to work like this.

     

    ONLY select users who havent logged in for 120days from the query (not selecting everyone, then figuring out the days)

    Use one query to delete all the old players (not one query for each player)

     

    Id really really appreciate any pointers or help that can be given to me!

     

     

  13. I found this on my travels, but how can i test it works how i want it to? like how can i test what it will select each time and check it is actuall choosing ads like 25% of the time etc. This is what my query now looks like, it returns banners, but i dont know if its weighting them or not?

     

    $result = mysql_query("SELECT * FROM tags WHERE ad_size='$ad_size' AND status='1'  ORDER BY Rand()*(1/weight) LIMIT 1");
    

     

    the additon being

     

    ORDER BY Rand()*(1/weight) LIMIT 1
    

     

  14. Hey all,

     

    Just looking for some quick help, iv googled around but nothings really coming up that i can appl into a query.

     

    I have an advert banner system and want to select a random banner id but have some more likely to display than others.

     

    mysql table has the columns (aswell as others), tag_id and tag_weight  ---  an example of the records would be

     

    id weight

    1 0.25

    2 0.25

    3 0.50

    4 0.40

     

    So i want tag_id 1 to show up 25% of the time or 25% more likely to show up in a rand() query.

     

    my query so far, without the weighted addition is

     

    $result = mysql_query("SELECT * FROM tags WHERE ad_size='$ad_size' AND active='1'  ORDER BY rand() LIMIT 1");
    

     

    My heads spinning when i think about how to work it out lol. How would i add in a weighted rand function to my query?

     

    Also would the weights all have to add up to 100?

     

    If i served 100,000 impressions and if i had  tag 1 set to 0.50 tag 2 set to 0.40 and tag 3 set to 0.30 .. which tags would show up how many times? If i set the weights added up to 100, im guessing that would each display like a percentage, so if tag 1 was weighted at 0.25 it would show roughly 25,000 impressions from the 100,000 correct? But what would happen if the weights dont add up to 100?

     

    im getting myself lost.

     

     

  15. Wow thanks so far.

     

    Gizmolo, I think I'd be interested in the cookie suggestion. Could you elaborate on this solution?

     

    I do get alot of schools and colleges on our site so many have the same ip, so I'm not sure an ip solution would work too well.

  16. Hey

     

    I have a little custom ad server script i made that just simply selects a random advertisers ad code and shows the advert and this works great.

     

    But now, I have an advertiser who wants to only show 4 impressions per user, per 24 hours. Im just totally stumped how to go about this.

     

    Whats the best way to limit showing a visitors something to x times per 24 hours?

     

    So my ad script runs, randomley selectcs an ad code but not one thats been shown to the visitors 4 times before.

     

    This is my "show advert" function that i call from around my site.

     

    function display_ad($ad_size) {
    
    $result = mysql_query("SELECT * FROM tags WHERE ad_size='$ad_size' AND status='1'  ORDER BY rand() LIMIT 1");
    $row = mysql_fetch_array($result);
    
    return $row['tag'];
    }
    

     

    As you can see as people navigate through the site, this ad code will show ads randomley. Im just clueless where to start "limiting ad views per 24 hours, per user".

     

    Any help or guidance would be very much appreciated!

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.