Jump to content
MakeWebGames

Floydian

Members
  • Posts

    900
  • Joined

  • Last visited

    Never

Everything posted by Floydian

  1. I added a lil deal to a game with a query like this:   $q_get = sprintf('select u.userid, u.username, u.level from users as u left join userstats as s on u.userid = s.userid where u.location = %d order by (s.strength + s.agility + s.guard) desc limit 3', $ir['location']); $q_get = $db->query($q_get);   And it took the page load time from about 1 second to about 10 seconds. Now, IMHO, that query isn't egregiously ill constructed, so it shouldn't completely destroy any performance the game was getting. It turns out, that putting a Primary Key index on the `userid` column of the `userstats` table brought the query execution time down from about 9 seconds to 0.02 seconds. mccodes userstats table doesn't come with an index on the userid column by default. Hope this helps a few folks...
  2. Re: How does Floydian do it? And there's another text talk! This brings the total number of javascript text talks to five. The last two javscript text talks demonstrate using an event handler to handle events on child elements. Rather than using 10, 20, 30 or more event handlers for 10, 20, 30 different elements respectively, we're just using one event handler for all of them at once. This event handler deals with the click event. If you needed a click/mouseover/mouseout/focus handlers, then you would need one event handler for each event type, but each one could still handle events on all the child elements in it. http://www.steelbreeze.us/index.php?p=soyouwanna Remember to post here if you have any questions or comments about the text talks.
  3. Floydian

    Input buttons

    Re: Input buttons IMHO, and I know there's *purists* out there that disagree (it's cool), using a javascript library makes adding cross browser compatible even listeners is pretty elementary. But it depends on how comfortable you are with javascript and the library if you choose to use one.
  4. Floydian

    Input buttons

    Re: Input buttons There's two things to overcome there, that I can see. The :hover pseudo attribute isn't recognized by IE 7/6 except for a very small set of elements. (mainly the A elements) So you're input button is going to lose that hovered state, unless you apply some javascript. The second problem would affect all browsers. The css code there relies on there being three elements. A parent, child and grandchild. So, you couldn't just put an input element inside a div and call it a day. You'd need to put it inside two divs, or a div and a span. Or some other combination of elements. Then you'd need to change the references to a and span in the css to suit the new elements. You'll likely have to make other changes as well, since input elements have different margins/padding/and whatnot you'll have to contend with.
  5. Re: How does Floydian do it? There's a new text talk available!
  6. Re: How does Floydian do it? Somewhere, Bill Clinton is still debating what the meaning of "is" is... I don't think anyone is arguing that javascript isn't a scripting language. I also don't think that anyone is arguing that a programmer sits down and writes programs in their language of choice. That programmer can be said to be writing a script if they are working with a scripting language. I hope that clears it up and brings us to a point of agreement.
  7. Re: How does Floydian do it?   After the kidding part, I summarize what the whole deal is about. The text talks aren't intended to teach as much as they are to document who I am as a programmer. Now if the techniques I use are helpful to someone, then that's great! But not everyone likes drink a Bananas Foster Latte', not everyone, in fact, most aren't going to do things the way I do.   I will speak to the question of javascript being a programming languang. Looking at the forum layout, HTML is listed as a child board of "Other Programming". HTML is definitely not a programming language. HTML is a markup language. There are no variables in HTML, no loops, no conditionals, no error handling, etc. The big difference between javascript and languages like C is that javascript isn't compiled. javascript has variables, conditionals, loops, error handling, is fully object oriented and more. In fact, javascript is far more object oriented than php. For instance, take this php code: <?php $number = (int) 1; Now, you can't do something like: $string = $number->toString(); In other words, variables that contain numbers in php have no intrinsic methods built into them like javascript does. All variables are objects of some sort unless the variable is undefined. Even a variable with the value null incorrectly identifies itself as an object.   Thanks for checking out the text talks. I hope you all have enjoyed them. :)
  8. Okay, you can stop laughing now! (sideways...) Oh alright alright, all kidding aside... I've decided to document who I am as a programmer. Since I'm a web developer, there's a number of technologies that I use. But being a web developer involves more than just programming, so I'm going to be talking about a number of different subjects including how I go about programming. How did I get my start, how do I work, and of course I'm going to be talking about the code. The big push right now, is on javascript programming. It's a very tough language to learn. But it's not because it's a hard language, but because the quality of tutorials is lacking. I can't tell you how much crap I've seen on the net as far as js tutorials. Almost none of them use js coding conventions. Pretty much none of them push non obtrusive techniques. And very few tutorials use a js library which I consider to be a must for all js developers. Now, this series of text talks isn't posted on this site for a number of reasons. First and foremost, I'm hosting live examples of the code which I can't do here. Secondly, I wanted more control over the formatting of the talks. I'm an HTML guy, not a bbcode guy... Thirdly, I wanted to be able to go back and edit at will, at any time, in case mistakes were made or typos are found. There is no discussion are on the site where this is hosted. It's not a commercial site. There is only one advertisement which is a referral link to the company I use for hosting. I encourage all readers to post their questions here on this site where I check daily and will respond to your questions/comments/suggestions and anything else you have for me. If I haven't lost you yet, I invite you to take part in my text talks series and I hope it helps you out a lot! Here's the link: http://www.steelbreeze.us/index.php?p=soyouwanna
  9. Re: HTML CSS Grids based layout (multi-column fluid pages) I've used the javascript deal to do this on http://www.phphorizons.com/ On any page on that site, viewing the source, and scrolling down a ways, and you'll see this js script:   <script type="text/javascript"> (function () { var Dom = YAHOO.util.Dom, Region = YAHOO.util.Region, Lang = YAHOO.lang, secondMenu, bdBlock, bdBlockRegion, sideBar, sideBarRegion, testOutPut, newHeight; secondMenu = new YAHOO.widget.Menu('secondMenu', { position: 'static' }); secondMenu.render(); testOutPut = Dom.get('testOutPut'); sideBar = Dom.get('sideBar'); bdBlock = Dom.get('bd'); sideBarRegion = Region.getRegion(sideBar); bdBlockRegion = Region.getRegion(bdBlock); if (bdBlockRegion.bottom > sideBarRegion.bottom) { newHeight = bdBlockRegion.bottom - sideBarRegion.top; sideBar.style.height = newHeight + 'px'; } // testOutPut.innerHTML = Lang.dump(bdBlockRegion); }()); </script>   It does use Yahoo UI though.
  10. Re: A simple, fast database class for PHP 4+ and MySQL You got it Karlos
  11. Re: HTML CSS Grids based layout (multi-column fluid pages) You're welcome Lithium ;)
  12. Re: HTML CSS Grids based layout (multi-column fluid pages) There isn't anything in css that will auto adjust a div's height to fill it's parent. You have to either change your design, or use javascript to calculate a static height for the div.
  13. Re: Updating an area with new text inputed by user? That recursive call to ajax_read() is killing the script. And you still have the script outside of the HTML tags...
  14. Re: Updating an area with new text inputed by user? Copied and pasted with permission to preserve the continuity of the thread. [20:58] <floydian> what's confusing ya about what I said in the forum? [20:58] <Sim> I dunno. what I do with innerHtml? [20:59] <floydian> first, you need to "get" the element you're putting the response into [20:59] <floydian> have you done that? [20:59] <Sim> hmm No. I don't know where to even begin with ajax. I downloaded an ajax chat example to try to learn from but it doesn't use mySQL. it uses a txt file. [21:00] <floydian> (and to make the thread make sense, I'll post what's said here so it closes up that thread nicely) [21:00] <Sim> Sounds good to me. [21:00] <floydian> it sounds like you need to study some ajax examples then [21:01] <floydian> there's lots of them out there [21:01] <Sim> http://ce.pastebin.com/m26c7883c [21:02] <Sim> I can figure out how to write to mySQL file without refreshing page. [21:02] <Sim> just not read from and update from mySQL [21:03] <Sim> Is it as simple as echoing? ;] [21:03] <floydian> # [21:03] <floydian> function ajax_read(url) { [21:03] <floydian> when you do that function call [21:03] <floydian> the URL you put in there [21:03] <floydian> will be executed as a normal page would [21:03] <floydian> and yes, anything you echo from that file that is executed [21:04] <floydian> would be placed into the web page [21:04] <floydian> by [21:04] <floydian> document.getElementById("chatwindow").innerHTML = xmlhttp.responseText;
  15. Re: Updating an area with new text inputed by user? element.innerHTML is a very common method. The innerHTML property sets the contents of the element and causes the browser to render any html that's included.
  16. Re: [uPDATED!] Basic ajax is easy It's a typo, and should be .html instead of .htm http://www.phphorizons.com/forum/exampl ... ajax3.html I'll see if I can't get the powers that be to make an edit.
  17. Re: [uPDATED!] Basic ajax is easy You're welcome ;) Check it, Firefox and IE are getting native JSON capabilities. This is sliced bread for browsers, trust me on this...
  18. Floydian

    What is Suhosin?

    Re: What is Suhosin? I'm guessing one of two things are true: No one here is using suhosin and/or no one here knows enough about it to tell you. Secondly: If anyone does, they obviously didn't feel bothered to reply.   (You can put me in the "I don't use it/don't know anything about it category") One thing I do know about Suhosin is that they have a nice web site with a lot of info. Read it ;)
  19. Re: Anything wrong with my database class? I don't know about anyone else, but my db class doesn't guarantee security. The class can be misused and it can be used correctly. The point: the class performs a job for you. It should make things easier. But using proper database escaping and variable typing in your queries is always going to be a function of a case by case basis. I.e., it's how you use the class that determines if it is secure.
  20. Re: Anything wrong with my database class? One word of caution, the more a query is "abstracted" and each component part (select/from/join/where/order by/group by/limit) is separated out, the harder it's going to be to secure those queries. Just sayin...
  21. Re: .htaccess or php help needed iamwicked, you're off on a tangent here. The topic is about using an index.php page which includes other files into it. For instance: // the attack page index.php?page=attack // the inventory page index.php?page=inventory The reason what I said wouldn't work on mccodes is because all the pages are accessed directly in the first place. Now, making sure no one accesses globals.php is probably pointless since globals.php appears on the second line of most mccodes scripts and would simply result in an empty page.
  22. Re: .htaccess or php help needed One method of ensuring your files are only accessed when you want them to, and this would apply to .php files is: In the index.php script, define a constant. Something like define('BLAHFOO', true, true);   Then scripts in the subfolder would get this code: if (!defined('BLAHFOO') ) {die();} This would be a standard way of locking down scripts, especially in applications that are distributed and forcing the person that installs the application to put one file in the public folder and another file somewhere else makes for a clumsy installation and it's not guaranteed that the user has access to files outside of the public folder.   Personally, I use this method because I like my folder/file hierarchy to reflect the actual hierarchy of the scripts in the application. Placing the main script in a folder deeper down in the folder system than the scripts that included into the main script, seems awkward to me. To be sure, it's great for security and I recommend using it. I do put crons out of the public folder. But then again, crons aren't included into the main script, so it fits the hierarchy. :)   Ze0n's method looks good on the surface, but has a security vulnerability in that, it's possible to fool that code...   Don't believe me, try adding a /asdf to the end of the script's url and see if you can't get past that "nifty" bit of basenamage :)
  23. Re: one of my mods deleted ? illusions, whilst I would normally back you 100%, out of the benefit of the doubt, the way you're trying to get your answer is 100% the wrong way. Number one, when you have a problem with something staff did, posting a thread in the forum questioning the staff is never going to put a smiley face on them. You really should have sent a private message to a staff member. Just trying to help you out illusions. I know for a fact, that you would get a better response (or one at all) by sending a private message rather than airing dirty laundry in the forum for everyone to see and smell. Thanks ;)
  24. Re: What would be better to use? hey hey hey, let's not neglect the old RIGHT JOIN ;)
  25. Re: Tables have border when set to 0 I did a view source for that. If you're looking in the php code, then the reason you don't see the br's is likely due to the br being somewhere in that array of table cells your looping through. That br is prolly outside of <td></td> tag which would cause the browser to place every one of them at the top of the table.
×
×
  • Create New...