Jump to content

Kryptix

Members
  • Posts

    283
  • Joined

  • Last visited

    Never

Everything posted by Kryptix

  1. I have a table with the following structure: OWNER - ID - SLOT - AMOUNT OWNER is the user ID who owns the item. ID is the ID of the item. SLOT is the position it's in within the inventory and AMOUNT is obviously the quantity. I need a script to find out what's the highest SLOT and then add a new entry into the next slot. How would you do this? I was going to query the database and ORDER BY `SLOT` DESC with only one result, and then do a new entry with $query['slot'] + 1 as the slot. Is there an easier, more efficient way to do this?
  2. Kryptix

    NOW()

    You are the absolute MAN! Thanks so much dude!
  3. Kryptix

    NOW()

    Perfect! Thanks! Now, is there a way to check to see if 'sub_expires' is => UNIX_TIMESTAMP()? So basically... if (sub_expires => UNIX_TIMESTAMP()) { UPDATE `users` SET `sub_expires` = sub_expires + 2592000 WHERE `id` = '101' } else { UPDATE `users` SET `sub_expires` = UNIX_TIMESTAMP() + 2592000 WHERE `id` = '101' } Is there anyway to do that in a single query?
  4. Kryptix

    NOW()

    It's not a Unix Timestamp, so directly adding a numerical amount of seconds to it has no meaning. What exactly are you trying to do? Go to Unix Time Stamp Generator and click the Now() button. It'll generate a Unix Time Stamp like 1259861291. I need to generate that in a query. I thought NOW() was the way to go but obviously not.
  5. Kryptix

    NOW()

    UPDATE `users` SET `sub_expires` = NOW( ) + '2592000' WHERE `id` = '101' This is returning 4294967295 when I expected it to return 128577889 (1259859889 + 2592000). I'm using Unix Time Stamp Generator as a test. Is NOW() different or something? I'm using this for a game where it checks to see if the user has subscribed. They purchase a subscription and it adds NOW() + '2592000' (30 days) to their 'sub_expires' column in their user entry. However, I'd like it to be able to detect the current entry and then add 30 days onto it, but what if the current entry is 60 days old? That'll just make it 30 days old... Right? I need it to basically check if their entry is => NOW() before adding '2592000' to it, otherwise just make reset the entry to NOW() + '2592000' (30 days). I hope that makes sense... I'm using Java for this. I would be able to write some checks in PHP but I'm not so good with Java so is there anyway to do this in a query?
  6. I haven't ever worked with this before but I need to make a script that will allow a user to pay for a monthly subscription. After they have paid it should add a entry into my database with a time so I can check when it expires (30 days). This should be really simple but I can't figure out how to do it with Google Checkout or PayPal. The instructions aren't clear and to be honest, I really don't know what I'm doing with it but I'm fine with PHP and MySQL programming. Does anyone know of any guides that will walk me through this? It should be one option, one price, one fixed payment type -- nothing complicated. It should just say "Buy a subscription", they pay and it credits their game account.
  7. Kryptix

    IRC Stats

    I need a PHP script that will display who's on IRC and stats like how many messages they've sent (etc). I'd be happy with a really light-weight copy that simply just says who's in the channel. I have no-idea where to start looking. Has anyone got any suggestions?
  8. Wow, thanks -- what exactly did that do and why did it only effect my site?
  9. It's fine when I view them externally (in a new tab), and they're fine when I upload them to ImageShack (etc). Every image on my website is blurry for me, but when I click through to the forum (using different XHTML and CSS) it's absolutely fine. I'm baffled...
  10. It seems that images on my website are really blurry on Firefox but not on Internet Explorer. If I view the image directly it's perfect, but whenever they're displayed on the website this happens. I can't find any reason why this would happen. Firefox: Internet Explorer: The website is: RSCEmulation Has anyone got any suggestions? EDIT: My friend just said it's blurry on his Chrome, Firefox and IE.
  11. I run a online game which wasn't coded by me originally. I've taken over the project and it uses a custom hash to encode a username into. Sometimes the encode_username() fails, it times out after 60 seconds. A player just tried to create the name 'Snoopy89' and it failed, so I tried and it worked first time. I then tried on his machine changing the case randomly and eventually it worked, even though on the 2nd line it strtolower() the string. It also fails if there's a underscore in the username, so I tried adding str_replace("_", " ", $username) but it still fails. For example, if I enter "TEST_ING" it'll fail even with str_replace() in place, but if I try "TEST ING" it'll work fine. I've done so much testing using this but it still sometimes randomly fails, and I can't figure out why. Unfortunately, there's over 800,000 database records using this format, and the entire game is coded to use this hash so it'd be very difficult changing it now. Other private servers use the exact same function with no problems. function encode_username($username) { $username = strtolower($username); $clean = ''; for($i = 0;$i < strlen($username);$i++) { $c = ord($username{$i}); if($c >= 97 && $c <= 122) { $clean .= chr($c); } else if($c >= 48 && $c <= 57) { $clean .= chr($c); } else { $clean .= ' '; } } $clean = trim($clean); if(strlen($clean) > 12) { $clean = substr($clean, 0, 12); } $hash = '0'; for($i = 0;$i < strlen($clean);$i++) { $c = ord($clean{$i}); $hash = bcmul($hash, 37); if($c >= 97 && $c <= 122) { $hash = bcadd($hash, (1 + $c) - 97); } else if($c >= 48 && $c <= 57) { $hash = bcadd($hash, (27 + $c) - 48); } } return $hash; } function decode_username($hash) { if(!$hash) { return 'invalid_name'; } $username = ''; while($hash) { $i = bcmod($hash, 37); $hash = bcdiv($hash, 37); if($i == '0') { $username = ' '.$username; } else if($i < 27) { if(bcmod($hash, 37) == '0') { $username = chr(($i + 65) - 1).$username; } else { $username = chr(($i + 97) - 1).$username; } } else { $username = chr(($i + 48) - 27).$username; } } return $username; } The code I'm using to use this function is: $encoded_user = encode_username(trim($_POST['char_username'])); $decoded_user = decode_username($encoded_user); Line 72 of server_functions.php is: if($i == '0') { $username = ' '.$username; } Any help would be greatly appreciated.
  12. Well, we had a variable called: $cname = "Kryptix"; We'd then remotely call that function... encode_username($cname); ...and it'd give us really weird results. We changed it to $bname and it worked fine. I presume the $c in $cname was causing the problems, as I've seen it happen before.
  13. PS. This is on a Windows Server 2003 machine running the latest XAMPP, but this happened to me years ago on shared Linux hosting too. I've always been really paranoid of variables and called them very tricky names just to make sure they don't clash with each other.
  14. Yes, it has happened to me in the past and just happened to me again. No, that wasn't the exact code, I just quickly typed it to give a simple example. Excuse the error, I was in a rush (yeah, that's what they all say). It just happened using this code... function encode_username($username) { $username = strtolower($username); $clean = ''; for($i = 0;$i < strlen($username);$i++) { $c = ord($username{$i}); if($c >= 97 && $c <= 122) { $clean .= chr($c); } else if($c >= 48 && $c <= 57) { $clean .= chr($c); } else { $clean .= ' '; } } $clean = trim($clean); if(strlen($clean) > 12) { $clean = substr($clean, 0, 12); } $hash = '0'; for($i = 0;$i < strlen($clean);$i++) { $c = ord($clean{$i}); $hash = bcmul($hash, 37); if($c >= 97 && $c <= 122) { $hash = bcadd($hash, (1 + $c) - 97); } else if($c >= 48 && $c <= 57) { $hash = bcadd($hash, (27 + $c) - 48); } } return $hash; } My friend wrote a form script that got their character name as a variable $cname. We couldn't see what the problem was, but after doing a Find & Replace (automatically) from $cname to $bname, it suddenly worked. We could only presume that the $c in the external function (which has been included) was overlapping and causing problems. I had this happen to me ages ago, but I took a long time away from PHP and only recently came back... But yeah, I'm 99.9% sure it does happen under some circumstances!
  15. In the past I've had variables clash. For example: <?php $c = 5; $cat = "Molly"; $echo $cat . " is " . $c . " years old."; ?> Before, I've seen it do: "5at is 5 years old." Is there anyway around this?
  16. I think that worked, but is there anyway to tell exactly what it deleted? It didn't give the result I expected, but of course, my original guess may have been off. I'm still a little scared to continue without knowing what happened though.
  17. I run a online game which is VERY MySQL based. We've been having some issues for a while now, which is allowing lots (40-150) of players logging-in at once. We don't know exactly where the problem is, but the exact same code run on other Linux servers works fine. Each login does about 8-10 queries from a large database. Is there any write restriction that can be increased or something? It's a 2.4 Quad Core processor and the CPU generally doesn't go higher than 30% but there's something, somewhere stopping this from working properly and it's becoming very difficult to track down. I'm running the standard installation of XAMPP.
  18. I have, I've bumped it 3 times now, no reply what-so-ever. I've just re-installed the latest copy of MySQL and it happens exactly the same. I'm at a lost end, what else is there to try? :'(
  19. MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0008 sec )
  20. I'm running XAMPP on Windows Server 2003 and have been for a few months now. When I first set it up I got this weird error in err.log: 091027 22:52:09 [Note] Event Scheduler: Purging the queue. 0 events 091027 22:52:09 InnoDB: Starting shutdown... 091027 22:52:10 InnoDB: Shutdown completed; log sequence number 0 69112 091027 22:52:10 [Note] PrimeBase XT Engine shutdown... 091027 22:52:10 [Warning] Forcing shutdown of 1 plugins 091027 22:52:10 [Note] C:\XAMPP\mysql\bin\mysqld.exe: Shutdown complete This went away randomly for ages, and then today it came back and proceeded to shut MySQL down every 13 minutes... I've renamed all the 'event' files in 'XAMPP\mysql\data\mysql' as well as trying to disable the 'event scheduler' via 'my.ini', but it says it's a unknown command. The guide I followed told me to try 'my.cfg' but I can't find this anywhere. Has anyone got any other ideas? This is really getting annoying now.
  21. Well it randomly resolved itself... It happened like 20 times and then just stopped.
×
×
  • 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.