Jump to content

Fog Juice

Members
  • Posts

    93
  • Joined

  • Last visited

    Never

Everything posted by Fog Juice

  1. I hope your not hacking with this. I have tried making one of these in the past... It failed. Maybe you should try javascript...? No it is nothing to do with hacking, to be honest it is actually part of a game. It doesn't have anything to do with wheels and bike locks. That was just the best I could do at giving a good example of what I'm trying to do without explaining the entire project. I would use javascript but I am not so good with it, I'm trying hard in PHP right now lol. Even if doing this in PHP is not as efficient, that's a sacrifice I'm willing to make to keep this only in PHP right now.
  2. $search = eregi_replace("([A-Z0-9]+)","",$_GET['search']);
  3. I've been struggling with this over the past few days and I can't seem to come up with the solution for what I'm trying to create. Suppose you have a bike combination lock with three wheels on it (one of those twist ones where there are 3 wheels, each side by side with numbers printed on each wheel). The wheels go between 0 and 15. Now suppose you have a random number generator that generates a set of 3 numbers, one for each wheel on the bike lock, and each random number generated is also between 0 and 15. And finally, suppose that the correct combination to unlock is defined by each wheel, so if the correct combination is 3,3,3 then it is $w1 = 3; $w2 = 3; $w3 = 3;, and the correct combination can be unlocked even if the wheels are offset by a total of 3. Meaning if $wh1 and $wh2 was equal to 3, and $wh3 was equal to 6 then it will still unlock. Or if $wh1, $wh2, and $wh3 all equaled 4, then that is still correct because the total offset of all 3 wheels combined is still 3. With each new random number set generated for the 3 bike lock wheels, what is the most appropriate and efficient way to check and see if the random number generated each time is the one defined as the correct combination?
  4. Hello, I have very minimal experience with .htaccess. I can write basic allow/deny etc but that's about it. What I am trying to figure out is how to permit multiple hostnames that all end with the same domain name. So for example, test1.domain.domainname.com, test2.domain.domainname.com should all be able to connect because they end in domainname.com. Does anyone have any suggestions on where I can look for a solution or maybe want to post an example? Thanks.
  5. damn you, I figured it out and was just about to post solution and close the thread but you beat me to it. lol. I thought it would be something more complicated. Thanks
  6. Hello, Suppose the following: $wh1 = rand(1, 16); $wh2 = rand(1, 16); $wh3 = rand(1, 16); I want to generate every combination of $wh1, $wh2, and $wh3. There will be 4,096 different combination but I want to print them out in a list for a little app I'm making. Before I even get started on doing this, can someone suggest what might be a better way to do this? I enjoy php but my math skills are not so great. Thanks.
  7. Hello, I only want servers with the hostname agni.lindenlab.com connecting to my script. The problem is, some of them have sim2342 in front so it could be sim2423.agni.lindenlab.com connecting or it could be sim6345.agni.lindenlab.com connecting. I'm really crappy at using preg_match() for these sort of things, can someone build me a preg_match that only matches agni.lindenlab.com with wtv else is in front but nothing past agni.lindenlab.com? I.e. I dont want someone mimicking agni.lindenlab.com with something like agni.lindenlab.com.myrealdomainname.net. Thanks so much!
  8. Is there a way to use the mod function so that it only returns 1 when ever a variable is on an increment of 10? So for example if a variable has reached 10, 20, 30, 100, 200, 1000 etc, is there a way to use mod to have it either return 1 if it is or 0 if it is not? Thanks.
  9. Um, say what? The OP asked about finding the index for an item in an array. strpos() is, obviously, for strings. Try this $index = array_search($array, max($array)); yes thank you, that is perfect. But I read in the php docs you have it backwards, array_search is array_search(needle, haystack). strpos is opposite where it is strpos(haystack, needle).. funny how they're opposite lol. But thanks a bunch, that's exactly what I needed.
  10. Is there a function or shortcut to find the position an array item is in when using the max() function? For example, if I have an array that goes $array = array(1,2,5,123,45,23) and I use max($array), it will return 123 which is in position 3 in the array, but is there a function to get that position? Thanks.
  11. Well pardon me, I guess I won't write you anymore free code examples either. I'm *edit* not *edit(my bad,forgot to say not.. lol)* looking for an argument but it just frustrated me to log in and see my post was moved with no explanation or anything. You can't expect users to know your intentions without warning them first. I appreciate your help but my first knee jerk reaction was "wth was that moved for", now it makes sense but like I said, you can't expect users to to know your intentions unless you tell them. Anyways thanks for trying to help in the first place, this forum is an excellent resource and is great for ppl like me who are out of college but still require a little bit of help every now and then.
  12. Thanks but I was looking for an answer native to MySQL, that is why it was in the MySQL section. I want to avoid having multiple SQL queries . I'm already using PHP atm for this, $return = mysql_query("UPDATE `games_linked` SET `server_id` = '$serverid' WHERE `game_id` = '$gid'"); if(mysql_affected_rows() == 0) { mysql_query("INSERT INTO `games_linked` (`id`,`server_id`,`game_id`) VALUES (NULL,'$serverid','$gid')") or die(mysql_error()); }
  13. If you are using the latest version of cPanel go to Databases -> Remote MySQL and from there add your IP address in the Host textbox and then click Add Host. You can get your ip address from http://whatismyip.com. One thing to be aware of is that your home ip address may not be static. Many ISP's charge premium for a static ip, so that means everytime your IP changes you'll have to add it to the host list (and preferably remove the old one you input last time). Also, make sure you never remove "192.168.1.%" which is in your host list by default. If you remove that, your server will not be able to connect to its databases.
  14. Why was this moved to PHP help? Clearly this is not a PHP question.
  15. Try to make sure you have remote access to the database first. Many times mysql is setup to only accept connections from the localhost and so you will have to add your IP address to the list of permitted connections. Are you using cPanel, directadmin, or do you have phpmyadmin installed on the server?
  16. I have the following query but I'm not sure of the exact syntax to use, this is what I want: IF NOT EXISTS(SELECT id FROM games_linked WHERE game_id = '$gid') BEGIN INSERT INTO `games_linked` (`id`,`server_id`,`game_id`) VALUES (NULL,'$serverid','$gid') END ELSE BEGIN UPDATE `games_linked` SET `server_id` = '$serverid' WHERE `game_id` = '$gid' END Does anyone have any suggestions for the correct syntax to make this work?
  17. something like this SELECT ga.name, g.id, g.game_id, g.uuid, g.date, ml.x, ml.y, ml.z, r.region_name, g.name as game_name FROM games_owned_by_avatar g, games ga, regions r, players p, machine_locations ml, games_linked gl WHERE g.owner_id = '".cleanup('', $_SESSION['user_id'])."' AND ga.id = g.game_id AND ml.game_id = g.id AND (gl.server_id IS NULL OR gl.server_id != '317') AND ml.region_id = r.id $filter GROUP BY g.id ORDER BY g.date DESC; but.. one that works. lol
  18. hmm I think I didn't ask the proper question, I'm really sorry. What i'm trying to do is select every row of 'games_owned_by_avatar' where it is owned by owner_id 17 and not having a secondary key included in games_linked where games_server id = 317. Basically I have a bunch of 'objects/games' that connect to different servers, each game needs to be linked to the server by the owner through a webpage I made. On the web page I list 1) all the games currently linked to the server selected, in this example it is server 317, and 2) all games that are currently not linked to the server by owned by owner_id 17. I dont want to dump the whole table structure here for anonymity reasons but I'm really stuck on this one having a brain fart. It's been awhile since I've done anything in mysql. What is below is def. wrong but any suggestions are helpful. SELECT ga.name, g.id, g.game_id, g.uuid, g.date, ml.x, ml.y, ml.z, r.region_name, g.name AS game_name FROM games_owned_by_avatar g, games ga, regions r, players p, machine_locations ml LEFT JOIN games_linked gl ON ( gl.server_id = '317' ) WHERE g.owner_id = '17' AND ga.id = g.game_id AND ml.game_id = g.id AND gl.server_id IS NULL AND ml.region_id = r.id GROUP BY g.id ORDER BY g.date DESC;
  19. Can you explain to me how to do it on my table1/table2 explanation? Sorry I do not quite understand even after reading some tutorials. :'(
  20. I've been looking at NOT EXISTS but what I don't understand is how can I use it to still display all the other values in a table. Below I want to select only the values from table2 that are not in table1. So that means only rows with id 5 and 6 would be selected. How can I do this? I think it is probably easy but i'm just having a hiccup. For example, Table1: id - id_table2 1 - 1 2 - 2 3 - 3 4 - 4 Table2: id - desc 1 - "hey" 2 - "hello" 3 - "sup" 4 - "example" 5 - "continues" 6 - "on" I should also add that this is a select with probably 6 different tables, I just simplified it for here.
  21. Or how would I select a value from another table only if a value in a different table doesn't exist?
  22. Hello, What I am trying to do is select the latest version of each uuid. Latest is determined by the unix time stamp in the date column. Below is the table with data, could someone give me a hint on how to do this? This probably seems easy but sometimes the easiest things are overlooked. Thanks! CREATE TABLE IF NOT EXISTS `phpfreakstableexample` ( `id` int(11) NOT NULL AUTO_INCREMENT, `uuid` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `date` varchar(255) COLLATE utf8_unicode_ci NOT NULL, `note` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=225 ;] INSERT INTO `phpfreakstableexample` (`id`, `uuid`, `date`, `note`) VALUES (1, '472541d7-3c51-8b2d-5acf-ea1d25cfacaa', '1245223150', 'test data for phpfreaks'), (2, 'd6e52102-dfa9-c570-7550-fe92d5517329', '1245223987', 'test data for phpfreaks'), (3, 'c4601d4c-d55e-16b3-11ff-85abba78a19a', '1245223988', 'test data for phpfreaks'), (4, 'c4601d4c-d55e-16b3-11ff-85abba78a19a', '1245223989', 'test data for phpfreaks'), (5, 'c4601d4c-d55e-16b3-11ff-85abba78a19a', '1245223990', 'test data for phpfreaks'), (6, 'd6e52102-dfa9-c570-7550-fe92d5517329', '1245223991', 'test data for phpfreaks'), (7, '472541d7-3c51-8b2d-5acf-ea1d25cfacaa', '1245223192', 'test data for phpfreaks'), (8, '472541d7-3c51-8b2d-5acf-ea1d25cfacaa', '1245223193', 'test data for phpfreaks'), (9, '472541d7-3c51-8b2d-5acf-ea1d25cfacaa', '1245223194', 'test data for phpfreaks'),
  23. Is it possible to only compare values in a WHERE clause if one of the values exists? For example, SELECT a.column, b.column FROM table a, table b WHERE a.some_id = b.id If b.id does not exist, is it possible to skip that whole comparison? Thanks.
  24. Hey all, I'm wondering if someone can point me to a good resource that will help me understand preg_match_all(). What I'm confused about is the string markup part and how it finds wtv string I'm looking for. For example, if I used preg_match_all('/<a([^>]+)\>(.*?)\<\/a\>/i', $this->markup, $links); that is supposed to give me <a> and </a> but I'm not exactly sure what all of the symbols etc mean. Does anyone have a resource to help me learn about this markup? Thank you.
×
×
  • 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.