Jump to content
MakeWebGames

Floydian

Members
  • Posts

    900
  • Joined

  • Last visited

    Never

Everything posted by Floydian

  1. Floydian

    template engine

    Re: template engine That include isn't dangerous if he's always passing a string that's hard coded in the script, which is what he's doing in that example.
  2. Re: Tables have border when set to 0 Here's what you have before the table with the map:   <script type="text/javascript" src="wz_tooltip.js"></script><div style="padding: 0px; overflow: hidden; visibility: hidden; position: absolute; width: 0px; left: 0px; top: 0px; z-index: 1010;" id="WzTtDiV"></div> <table border="0" cellpadding="0" cellspacing="0" width="">   I'm guessing those brrrr's are the culprit ;)
  3. Re: forum posts When I said: "select topic from forum_topics order by last_post_date desc limit 10", keep in mind that I don't know how your forum is setup. I don't know what the table names or column names are. I don't even know if it uses a database in the first place. The mysql query I posted is *representative* of how a query could be crafted that would get the last 10 topics posted in.   I will say that your code is a long way off from what it needs to be, if indeed you are getting your data from a database.
  4. Re: What would be better to use? Unless you're planning on running that query 10 million times, the difference between either of those doesn't amount to a hill of beans.
  5. Re: forum posts select topic from forum_topics order by last_post_date desc limit 10
  6. Re: Need help with Ajax good to hear and you're welcome ;)
  7. Re: Need help with Ajax can you post a link to a working example?
  8. Re: [FAQ] Before posting An Error That's a good one to do as well POG1. I find MySQL Administrator/Query Browser to be especially useful for that sort of thing. Although, if you're on a shared server, you might not be able to get access to a remote MySQL connection
  9. Re: [FAQ] Before posting An Error It's true the "or die" method isn't the best. It's also true that using the "or die" method is a lot better than not using any mysql debugging at all. :)   Nice topic Haunted Dawg. If people follow this, it will be very helpful for them indeed!
  10. Re: Tables have border when set to 0 Glad that worked ;) All I'm seeing is a blank white page.
  11. Re: Tables have border when set to 0 try: cellspacing="0" cellpadding="0"   The css way to do that is: style="border-collapse: collapse" ---- that would be used on the table tag
  12. I'm sure most of us have run across a file on a server that has had lots of line breaks inserted in it. I've seen it happen a lot when moving a file from one folder to another. cpanel seems to be pretty bad with this. (that's in my humble opinion though, based on experience) Whilst this isn't a major problem, I thought I'd share a little script I made that gets rid of some of those line breaks. Since we do want to preserve the line breaks that were in the file originally, we'll do a selective removal of the line breaks. The basic code goes like this:   <?php $file = file('some_file.php'); echo '<pre>'; $count = 0; foreach ($file as $line_num => $line) { if (strlen(str_replace("\n", "", $line)) < 1) { if ($count % 2) { $line = str_replace("\n", "", $line); } $count++; } echo htmlentities($line); } echo '</pre>';   That will print to the screen your file with the extra line breaks removed. Simply copy and paste it into your "exploded" file. I affectionately refer to files affected by these extra line breaks as exploded files. ^__^ If your file has been exploded more than once, you can run this script as many times as needed, copying and pasting the code each time. Or you can add in extra for loops. The for loop has to be a bit different, so to demonstrate:   <?php $file = file('some_file.php'); echo '<pre>'; ### THIS IS THE LOOP YOU CAN COPY ### $count = 0; foreach ($file as $line_num => &$line) { if (strlen(str_replace("\n", "", $line)) < 1) { if ($count % 2) { $line = str_replace("\n", "", $line); } $count++; } } unset($line); ### END OF THE THIS IS THE LOOP YOU CAN COPY ### $count = 0; foreach ($file as $line_num => $line) { if (strlen(str_replace("\n", "", $line)) < 1) { if ($count % 2) { $line = str_replace("\n", "", $line); } $count++; } echo htmlentities($line); } echo '</pre>';   If your file had been exploded three times, you would copy that middle section one time, so that you'd have two of those sections. If you need to clear out a quadruply exploded file, copy that center section twice. Of course this script exposes the code contained in whatever file you put in on this line -- $file = file('some_file.php'); -- So if you have top secret super sensitive code, keep that in mind.
  13. Re: how to always show scrollbars? good deal ;)
  14. Re: how to always show scrollbars? I made a map there 32 squares by 32 squares, it came out square. (incidentally, it did have scrollbars) I see yours is 20 by 5. I'm not sure what you're looking for as well.
  15. Re: how to always show scrollbars? Scroll bars show up in many places and they come in two forms, horizontal and vertical. Can you be a bit more specific?
  16. Re: What is the difference between an ID and a class? POG1 one pretty much summed it all up. There's another thing I'd add to that, which is: You can only have one id on an element. You can have any number of classes on an element. For instance, suppose you make a class for bolding text, aligning text, and another one for making text small. You could apply those like this:   <style> .bold { font-weight: bold; } .left { text-align: left; } .small { font-size: 9px; } </style> <p class="bold left small">...............................</p>
  17. Re: Tab menu problem It's really impossible to know for sure what the solution is without a test case. Put up a link to the site and I or someone else would be able to provide a definitive answer. With that said, I wonder if a text-align is being set to center for some reason.
  18. Re: money_formatter on MCCODES V2 the topic creator ;)
  19. Re: money_formatter on MCCODES V2 To provide a reason that didn't work, you can't have square brackets as part of the function signature. function blah($foo[$umm]) The [$umm] part just can't be added in. I doubt that $foo->umm would work either.
  20. Floydian

    sprintf() Query..

    Re: sprintf() Query..   I don't know C++ unfortunately. But the manual does say: "u - the argument is treated as an integer, and presented as an unsigned decimal number. " I'll amend what I said previously and replace it with that.
  21. Floydian

    sprintf() Query..

    Re: sprintf() Query..   A signed integer can be positive or negative. %u -- an unsigned integer, is always positive. It doesn't matter if you use %d or %u. Neither one is better or worse, secure, or insecure. Again, what matters is larger than the subtle distinctions between sprintf's formatters. Here's what most people seem to miss: sprintf() is used to format a string. That's it. It's not magic; it's not Fort Knox; it just formats a string.
  22. Floydian

    sprintf() Query..

    Re: sprintf() Query.. It's neither secure or insecure. The governing factor here is context. An unsigned integer has benefits for sure but consider this: you have a script where you buy an item in quantity. You pass in the item id and the quantity. The script calculates total cost, checks if you have enough, and then subtracts that amount. For brevity, let's skip ahead of some of the preliminaries and get to the meat of the script.   /* Posted vars: $item_id $quantity Result from query: $cost $users_money */ $total_cost = $quantity * $cost; if ($users_money < $total_cost) { die('not enough cash'); } else { mysql_query(sprintf('update users set money = money - %u where userid = %d', $total_cost, $userid); }   What could be the problem here? What if the quantity the person put in was negative? $total_cost would then be a negative number. The user would presumably always have more cash than a negative amount. Therefore, in this context, the code, holistically, is insecure. Definition of holistic: specifically definition #2 There is however nothing wrong with the sprintf function call or the params passed into it. The problem, potentially, is blindly relying on a single portion of code to provide security to the whole. It just doesn't work that way I'm afraid.
  23. Re: Problem with gzfile() in php5.2 The second parameter for gzfile is defined like this in the PHP manual: use_include_path You can set this optional parameter to 1, if you want to search for the file in the include_path too.   So you can leave out that param, like was said already, or you can set it to 1. "r" or any other letter won't work there. :)
  24. Re: Block multiple logins Sessions are completely new each time they are created. The session id is a random deal. Now any info you store in that session is another matter entirely...
  25. Re: Simple MySQL optimization   This thread dates to August, not quite sure why it was resurrected. Anyways, Nyna and I were feuding, hence the nice dig comment. That's pretty much all this was about. Clearly removing parens and relying strictly on order of operations is nothing to worry about.   However, I would make the argument that many times more parens actually make code less readable...   If you think ---- WHERE ((bankmoney >= 0) AND (fedjail <= 0) AND (last_login >= (UNIX_TIMESTAMP() - (3 * 86400)))) is more readable than ---- WHERE bankmoney >= 0 AND fedjail <= 0 AND last_login >= UNIX_TIMESTAMP() - 3 * 86400 Then there is nothing I can do for you. There's only one set of parens I could see adding in, and only because one might want to clear up any order of operation confusion in noobs.   WHERE bankmoney >= 0 AND fedjail <= 0 AND last_login >= UNIX_TIMESTAMP() - (3 * 86400) That IMHO is no more readable than the above example but is more dummy proof.
×
×
  • Create New...