Jump to content

Kryptix

Members
  • Posts

    283
  • Joined

  • Last visited

    Never

Everything posted by Kryptix

  1. I'm making a country selection with a drop down menu and have 200 countries in PNG format (16 x 11 pixels or something close to that). I can loop through them all and display them in a list fine but I need to know how to add a image into the actual drop down menu. I've never done this before and don't know how to do it. Any ideas?
  2. Thank you very much gizmola, quality post.
  3. If you download TeamViewer I'll do this remotely for you so you can watch and learn but it's far too much to explain if you have never even used MySQL before. My MSN is: luke@xa0s.com
  4. I tried using PROCEDURE ANALYSE on a table of mine and saw the Optimal_fieldtype suggestion and had a few questions. 1. What's the difference between TINYINT, SMALLINT and INT (etc)? Some said the best option was TINYINT(3) and in another field it said the best option was SMALLINT(3), so what exactly is the difference between them? Also, what's the minimum and maximum value for each? Same with MEDIUMINT and BIGINT please. 2. I have a lot of fields where they will only contain either 1 or 0 so it suggested using ENUM('0','1') NOT NULL. However, phpMyAdmin doesn't seem to have a GUI for that so how would I change a column TINYINT(1) to ENUM('0','1'), and is it OK to do the same with a column that will only ever be 1, 2, 3, 4, 5 or 6 using ENUM('0','1','2','3','4','5','6')? 3. What's the best field setting to use for a MD5 encrypted password? I'm currently using VARCHAR(32) but it's suggesting CHAR(32). Which should I use and why? 4. When it says SMALLINT(5) UNSIGNED NOT NULL, what does UNSIGNED mean? Thanks to whoever is patient enough to answer.
  5. I run a little game and when it loops through saving the players progress it wipes their inventory with the following query: databaseConnection.updateQuery("DELETE FROM `rscd_invitems` WHERE `user` = '" + save.getUsernameHash() + "'"); It then checks to see if they have any items in their inventory, and if so, loops through extending the query: if (save.getInventory().size() > 0) { query = "INSERT INTO `rscd_invitems` (`user`, `id`, `amount`, `wielded`, `slot`) VALUES "; int slot = 0; for (InvItem item : save.getInventory().getItems()) { query += "('" + save.getUsernameHash() + "', '" + item.getID() + "', '" + item.getAmount() + "', '" + (item.isWielded() ? 1 : 0) + "', '" + (slot++) + "'), "; } databaseConnection.updateQuery(query.substring(0, query.length() - 2)); } This is absolutely fine except if the server crashes half way through the process it leaves them with a wiped inventory. Today someone told me about transactions but I'm not entirely sure how to use them. I thought I could do something like this: START TRANSACTION; DELETE FROM `rscd_invitems` WHERE `user` = '918'; INSERT INTO `rscd_invitems` (`user`, `id`, `amount`, `wielded`, `slot`) VALUES ('918', '1', '1', '0', '0'); COMMIT; The problem is, with Java you need to do it differently as you can't put multiple queries on one line. Does anyone know how to do this? I appreciate that it's kind of a Java question but someone here might know. I've seen a few examples but don't really understand them, all the examples I've found are quite different from what I'm trying to do.
  6. Kryptix

    Timer

    I want to update the user online count every second, how would I run a timer within JS/Ajax?
  7. JAY6390's answer was perfect. Thank-you.
  8. I'm pretty new to all of this, could you show me how to add a time limit? var xmlhttp; function checkCharacter(str) { xmlhttp = GetXmlHttpObject(); document.getElementById("character").innerHTML = "Loading..."; xmlhttp.onreadystatechange = stateChanged; xmlhttp.open("GET", "getuser.php?character=" + str, true); xmlhttp.send(null); } function stateChanged() { if (xmlhttp.readyState == 4) document.getElementById("character").innerHTML = xmlhttp.responseText; } function GetXmlHttpObject() { if (window.XMLHttpRequest) return new XMLHttpRequest(); if (window.ActiveXObject) return new ActiveXObject("Microsoft.XMLHTTP"); return null; } Also, I want to make various functions like checkAccount() and checkPassword(), do I really need a separate stateChanged() for each of those or is there a way to combine them?
  9. When doing live searches, do you really do a database query for every key they push or do you generate XML every 30 mins or whatever and then search the XML? I run quite a busy site and I can imagine people typing tons of random stuff just to put the server under strain and so on. What do you guys do? Maybe have it detect the server load before offering live search? I want to do it for form registration, checking to see if a username is taken and so on.
  10. Hm, OK. Could you show me how to do an UPDATE JOIN please?
  11. UPDATE `rscd_quests` SET (`quest_stage`, `finished`) VALUES ('0', '0') WHERE `user` = '0' AND `quest_id` = '0' Is it possible to insert into another table too within the same query? Say for example I wanted to do the exact same but into `rscd_quests2` as well.
  12. Hm, this is confusing. Is MySQL's TIMESTAMP the same as TIME() in PHP and UNIX_TIMESTAMP() in MySQL? I have thousands of database entries and it would be a pain to switch.
  13. Well, how would you do it? It's a trade logging system for a RPG. There's 2 players, each with 12 inventory spaces. Every item has to be logged so we can search by item ID. I don't want to have a string in a VARCHAR so I couldn't think of any other way.
  14. `user1_item1` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item2` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item3` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item4` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item5` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item5` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item7` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item6` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item9` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item10` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item11` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user1_item12` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item1` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item2` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item3` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item4` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item5` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item5` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item7` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item6` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item9` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item10` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item11` LIKE '" . $db->escape($_POST['item_id']) . "' OR `user2_item12` LIKE '" . $db->escape($_POST['item_id']) . "' If there anyway I can do like: `user%_item%` LIKE '" . $db->escape($_POST['item_id']) . "'?
  15. Hi chaps, I have a table with a column called 'time' which is PHP's TIME() or MySQL's UNIX_TIMESTAMP(), I need to allow a user to search between two certain times. They should be able to specify the start time and the end time and it will show all results before then. The 'time' column is obviously a INT (10), what query would I use? Something like this, or is there something more specific? SELECT * FROM `table` WHERE `time` > '" . $start . "' AND `time` < '" . $end . "' Also, does anyone know of a script or whatever where you can select a date from a pop-up window or something? What's the function to turn 01/12/2009 into a TIME()?
  16. I use UNIX_TIMESTAMP() a lot, is there anyway I can use that as a default value? It's a INT(10) and if I put UNIX_TIMESTAMP() in it says it's invalid.
  17. Can you make a var name by doing something like this: <?php for ($i = 0; $i < 5; $i++) { $var . $i = "Var " . $i . " set...<br />"; } echo $var1; echo $var2; echo $var3; echo $var4; ?> Is it possible at all? I really need to do it, make a variable name whatever the loop count is.
  18. I've posted about this before but I still haven't resolved this. I run a online game which is SQL hungry, and when a player logs in it executes around 8 queries instantly. If we restart the game server and hundreds of players are trying to login it will only accept one every second or two when it's going slow, which is far too long and causes other bits to mess up. When it's running properly it's one every 0.1-0.4 second but I don't know why it's going slow. I found out ages ago that my index was wrong and after speaking to a friend we got it fixed and it was perfect for about 2 weeks and then randomly it just went really slow again. I messed around with the indexes again, pretty much just removing them and adding it back and it fixed it. A few weeks later and it happens again... This time, no matter what I try I can't get it to go back to normal. I just put up with it for ages and when I transferred to another host it worked again and was perfect but again, a week or two later and it went slow again. I then dropped the database and re-imported it which fixed it again for a few weeks, but now no matter what I do, nothing is resolving it. I'm at my wits end, it's sooo annoying and I can't find any pattern with it. Why would queries start to just go slow? Is there anything I can do to speed them up? What's the optimize table button do (etc)?
  19. I have a FAQ page and I really want them to be clickable links that hide and show the answer when you click the question. http://86.7.138.3/RSCE/faq.html Could someone point me in the direction of a script that will allow me to do that? Either JS or CSS would be great. I really have no-idea where to even start.
  20. Kryptix

    Spaces

    Some people sign up with their name as "SPACE HERE" and have like 10 spaces in-between each word, I need it so they can only have one space at a time. How would I do this?
  21. Anyone know why? I thought it was a INDEX issue at first, but now I know otherwise. I run a online game and when starting the game up 100-200 players try logging in at once which generates 5-6 queries each, and after a day or two of running these become very, very slow and end up messing the game up. Restart MySQL and all is good again, for another day or two. This never happened before. It's Windows Server 2003, latest version of MySQL originally installed through XAMPP. Any help would be appreciated. I'm pretty new to this.
  22. I understand how it works but it's getting it working that I'm struggling with. Will the script above work?
×
×
  • 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.