
Floydian
Members-
Posts
900 -
Joined
-
Last visited
Never
Content Type
Profiles
Forums
Events
Everything posted by Floydian
-
Re: Whats going on? I'll preface this by saying that I suck with regex... My guess would be the "com" in welcome is getting caught up by: (eregi(".com", $_POST['message'])) perhaps the "dot" is some sort of control that needs to be escaped? I'm sure Nyna will know for sure what the deal is. I stay away from ereg as much as is humanly possible. However, I wrote a fully comprehensive mail filter that works 100% and in that I did use some ereg, if I recall correctly. But I did it in a far different way. I think I used arrays for matching parameters and whatnot. Perhaps I'll post it somewhere for ya'll ;)
-
Re: Simple Funtions pog-one, that's a good point, however, it's not necessary most of the time. Most scripts I make for my game or other people's games, have like four or five cases. Splitting one file, such as attack.php over five seperate files is just ridiculous IMHO. At least, splitting it up in some sort of haphazzard way as doing one function in each file is overkill. Files should be split according to the logic flow. For instance, mccodes has a glob_func.php file with many functions in it common to many files. globals.php is good since a header and footer is needed on every page. But, take attack.php. Do you really need an attacklost.php? and an attackwon.php? For god sakes! pog-one, I'm definitely in agreement with you that splitting up files like you're talking about is very useful in the right situation. A perfect place for this is the admin panel. You could have all user related functions in one file, log functions in another, and so on. Any staff functions that only need one function could be in the main staff file or in a staff/misc.php file.
-
Simple MySQL optimization
Floydian replied to Floydian's topic in MySQL, Oracle, Postgress or other DB
Re: Simple MySQL optimization Sure thing ;) I've read many parts of the manuals more times than I care to remember. lol, I've even read many of the comments people post. There's some fantastic stuff in there for those that want to get some more optimization techniques straight from the developers. :) -
It's a small optimization, but something I see in a lot of noobish code... Take for instance, a query like this: UPDATE users SET bankmoney = bankmoney + 10000 WHERE ((bankmoney >= 0) AND (fedjail <= 0) AND (last_login >= (UNIX_TIMESTAMP() - (3 * 86400)))) The MySQL manual states the following about optimization of the where clause: A query like the one above could be written like this: UPDATE users SET bankmoney = bankmoney + 10000 WHERE bankmoney >= 0 AND fedjail <= 0 AND last_login >= UNIX_TIMESTAMP() - 3 * 86400 All those extra parenthesis don't actually do anything for this query. The one tricky part is at the end. UNIX_TIMESTAMP() - 3 * 86400 Because MySQL follows mathematical order of operations 3 is multiplied by 86400 first, and then that value is subtracted from the current unix timestamp. Thus, even the parenthesis used to force execution order there are unnecessary. I hope this helps. Naturally, this is one of those deals that is akin to the difference of print and echo. I wouldn't go through thousands of lines of code removing parenthesis, but I certainly wouldn't write new code that was bogged down with them either. Happy MySQL'in folks! And stay tuned for the next installment of the Horizons Workshop!
-
Re: issues with my forums alternatively, you can try placing this line before your query: global $db;
-
Re: Create user problem I can't hardly stand it.... signedup, email, bankmoney, creditcard You have a unix timestamp, you have a series of numbers, which is obviously bankmoney, and a -1 What's missing in that? THE EMAIL lol
-
Re: I Nedd a coder So the coder gets to do all the work, and you get to keep 80% of the profit? Nice one. I'm offering 10% profits to anyone that wants to code, host, and manage a game for me. I'm available for emotional support, if you need it.
-
Re: Create user problem There's 22 of these: And 21 of these: Somewhere, you missed a value. Hence the column count error. ;)
-
Re: Query help please where blah = blah aaaaaaaaaaaaaaaannnnnnnnnnnnndddddddddd something = something you used a comma instead of and
-
Re: Query help please if($rcollect == 2) { $item=$db->query("SELECT * FROM items WHERE itmid=1",$c); print "you find a Research Centre Area 1 Key Card. You pocket the key card and head out of the research centre."; $db->query("UPDATE users SET collect=1 WHERE userid=$userid",$c); $db->query("INSERT INTO inventory VALUES('',1,$userid,1)",$c); event_add($ir['userid'],"You find a ['itmname'] while searching the research centre.",$c); } Note that I change $item to 1 in the line: $db->query("INSERT INTO inventory VALUES('',1,$userid,1)",$c); Give that a shot.
-
Re: Php & SQL Coder Needed for MMORPG PHP Horizons isn't interested in partnerships, but should you ever need top notch programming we're here for you. Our code is in place a many games, more than I can remember lol. You can find many examples of our work at www.phphorizons.com. Good luck with your game ;)
-
I want to make/own my own game, please help
Floydian replied to NickH440's topic in Other Programming
Re: I want to make/own my own game, please help lol @ leen's shameless advertising I'll upload your code to a web page for $10 bucks. Deal? :P -
Re: Simple Question That's what's up ;) I've worked with a lot of code that has print in it. Almost half of cove of pirates.com uses print. But anything new gets all echo's ') Good luck!
-
Re: Magic Quotes Help I gave you the whm idea. But you haven't answered the question of whether or not you have WHM. If you have that, you should follow the guidelines I layout. --------- To Zeon: That was a pointless post. It's off topic, and doesn't help. What are you some sort of heckler or something?
-
Re: Magic Quotes Help lol Zeon that was about as pointless as a forum post can get. What makes you think this person can edit their php ini when they're going the .htaccess route? -------------------- Anyways, on to the serious help. You say you're on a virtual server which means the installation of php is running just for you and does not run scripts for other people on a shared server. Do you have WHM? If yes, then go into WHM, type "php" into the Find box on the top left. Select "PHP Configuration Editor" Select "Switch to Advanced Mode. " Find magic quotes on the list, and set the setting to whatever you want. And WHM will automatically restart apache for you. If you don't have WHM, then your web host (in this case Go Daddy) can edit your php ini file for you.
-
Re: Simple Question In all seriousness, you'd be wasting your time making that replacement. I think people that are new to coding are very keen to make things as efficient as they can. But when you get to be an old and jaded coder like me, you'll be far less likely to feel the urge to implement such changes as a print to echo replacement because you'll have realized long ago that it would make virtually no difference and that your time would be better spent elsewhere doing some real optimization. ;) Or in the case of someone new to coding, time would be better spent writing new code or studying.
-
Re: How would i shorten this Na, you'll be alright :P
-
Re: How would i shorten this lol => ereg('[^0-9]', $_GET['time']) that's the ole "swatting a fly with a sledgehammer" deal. why not use the native is_numeric() function? By the way, wouldn't the order of that need to be switched up? <?php if(isset($_GET['time']) AND ereg('[^0-9]', $_GET['time'])) { $time = $_GET['time']; } else { $time = 15; } ?> :O
-
Re: Changing Brave Field update users set maxbrave = 15 the column name maxbrave might be wrong. it could be max_brave. but that query is the general gist of it. to update one person: update users set maxbrave = 15 WHERE userid = 1234 ;)
-
Re: Main Menu help! Two words of caution when using css style sheets and html markup for these menus. Browser differences. IE doesn't support the onhover event on anything except for the a tag. Document Type Almost all of these css drop down menus fail in IE if you aren't using an XHTML doc type. YAHOO solves these problems by providing an API that normalizes these things, which is why I recommend it. Of course this means that css based drop down menus are good to use, but you should be aware of the potential pitfalls.
-
Re: Firefox 3 Opera is good, but nothing beats Firefox from a developer's stand point. FireBug, a Firefox extension, is invaluable for development. As far as general browsing, IE7, Opera, and Firefox are all good browsers. And any web developer worth their salt should be making their web apps compatible with all three of those at least. Firefox 3 specifically is pretty nice. The only qualm I have about it is if you installed one of the betas for Firefox 3, and then went back to Firefox 2, you probably will lost some of your profile when you upgrade to Firefox 3. I had to do some copying, deleting, and renaming of files in order to get back most of my profile.
-
Re: Main Menu help! Drop down, and fly out menus are one of the hardest design elements to master. I recommend checking out YAHOO YUI, specifically the Menu components. They do most of the formatting work for you. You can see examples of YUI Menus, and all of it's documentation here: http://developer.yahoo.com/yui/menu/
-
Re: Basic Ajax is easy good question Jeff Here's how you do this. I'm going to take all of the old comments out, and comment the places where I change this function, and then explain them in a bit more detail after I show the example. // <?php PLEASE NOTE THAT THE PHP TAGS ARE ADDED IN ONLY TO FORCE COLORIZING OF THE CODE. ;) // Add in more parameters to the function. function js_function_1(submission, var1, var2, var3) { ajax_object = ajax_create() if (ajax_object) { // Add on to the end of this by concatenating the new parameters you have passed. ajax_object.open('get', './do_ajax.php?action='+encodeURIComponent(submission)+'&var1='+encodeURIComponent(var1)+'&var2='+encodeURIComponent(var2)+'&var3='+encodeURIComponent(var3)); ajax_object.onreadystatechange = function() { if (ajax_object.readyState == 4 && ajax_object.status == 200) { handle_check() } } ajax_object.send(null); } else { document.getElementById('ajax_output').innerHTML = 'Please file a bug tracker report.'; } } // End of js_function_1() function. // ?> PLEASE NOTE THAT THE PHP TAGS ARE ADDED IN ONLY TO FORCE COLORIZING OF THE CODE. ;) The first thing we have to do is make room for the function to accept more parameters besides the "submission" parameter. function js_function_1(submission, var1, var2, var3) { We've added in three more, in this case. You can pass these to the function by writing your a href as follows: Click here to move on the map. We are only using submission, var1, and var2. In javascript, that's okay. var3 doesn't require that anything be passed to it. ____________________________________________ Now that we're passing the values we want to pass to the function, we have to submit them via an ajax object, i.e., ajax_object.open() ajax_object.open('get', './do_ajax.php?action='+encodeURIComponent(submission)+'&var1='+encodeURIComponent(var1)+'&var2='+encodeURIComponent(var2)+'&var3='+encodeURIComponent(var3)); We've added on a few things here. encodeURIComponent is basically the same thing as PHP's url_encode(). It formats a string into an acceptable URL format. This string could be written out a bit shorter, and perhaps it might make it more clear what is going on. ajax_object.open('get', './do_ajax.php?action='+submission+'&var1='+var1+'&var2='+var2+'&var3='+var3); We've taken out all of the encodeURIComponent functions for demonstration purposes only. We can strip it down a bit more. './do_ajax.php?action=' + submission + '&var1=' + var1 + '&var2=' + var2 + '&var3=' + var3 See how we're building a URL? We can add in more variables if we need to. I think GET has a limit of 100 characters, so keep that in mind. You can do POST, but it's a bit more difficult. Does that clear it up a bit?
-
Re: Cant get my head around these? Fixed ;)
-
Re: Cant get my head around these? The best way to fix this is to figure out a reliable way to reproduce any of these bugs and thoroughly debug them, unless someone else has encountered the exact same set of circumstances. Without testing the code out, I certainly won't be able to offer any advice on this one.