Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. The error would suggest that there's a problem with your query. Try adding some debugging and see what the problem is. Change this: $result = mysql_query($query); To $result = mysql_query($query) or trigger_error(mysql_error(),E_USER_ERROR); p.s. In future posts, try to use tags around your code. And welcome to the forums
  2. I don't see how that's possible. For example. If i tell you a particular element has a depth of 2, can you tell me which parent it has? Sure you can tell me it's parent has a depth of 1, but you can't tell me which parent it belongs to. Unless of course the ordering is guaranteed such that if the depth increases you know that the child belongs to the most recent node with a depth one less than it.
  3. Quite possibly. It would certainly be more representative of the actual data. It's just, depending on how you store your data, it might be easier to produce my representation of the data rather than yours. If, for example, we just store the parent node alongside the child node in a database, it would be very easy to select all the rows once and run through it producing my array. Unless im missing something simple, i think it'd be more difficult to work out where each row belongs in your array. On the other hand, i suspect your representation would be easier to search and would consume less memory, since we're only passing part of the array into the recursive function each time we call it.
  4. 1.) Use tags around your code -- you need to put the opening tag before your code, and the closing tag after. You know, kinda like all that HTML you're outputting. 2.) Try narrowing down the problem. No-ones going to sift through that code. 3.) Why don't you try seeing if you can get the output you desire on a separate page, without all the other crap going on. You can use the sleep function to simulate a long process.
  5. No idea. What does your execute method look like? Do you get any errors? What actually happens?
  6. The is_numeric function will allow signed numbers. It'll also allow decimal and exponential parts. If you want to ensure the string only contains decimal digits, use the ctype_digit function. As for why it's been inserted as 2^32-1; i'm not overly sure. Evidently there's some sort of overflow going on somewhere. What type is the field? Do you do anything else to $phone before it's inserted?
  7. Yes, you can send data to the browser while php is still executing. If you do this, you cannot then alter the data, however. PHP runs on the server side. Essentially, once the data is gone, it's gone. If you wish to have the text change, you'll want something along the lines of an AJAX request. If you google for some AJAX tutorials, you'll find all that you need. If you just want to add to it, then you can just use the flush function.
  8. Because you have a few syntax errors: <?php if($_POST['dmoney']) { if($player->money > $_POST['dmoney']) //missing closing bracket { header('Location: ../your_gang/vault.php'); //missing semi-colon } elseif($player->money <= $_POST['dmoney']) { $query = $db->execute("update `players` set `money`=? where `id`=?", array($player->money - $_POST['dmoney'], $player->id )); $query = $db->execute("update `gang` set `money`=? where `id`=?", array($gang->money + $_POST['dmoney'], $gang->id )); } } ?>
  9. I think you're going to struggle with this using an array in the way you are -- you need to store the relationship between the child node and the parent node. For things like this, i usually store the parent node as the key of the array, the value of which is all the children. Something like this: $array['root'] = array('ROOT1','ROOT2'); $array['ROOT1'] = array('CHILD 1 OF ROOT 1','CHILD 2 OF ROOT 1'); $array['CHILD 2 OF ROOT 1'] = array('CHILD 1 OF CHILD 2'); Then, you can use a recursive function like so: function listElements($array,$index='root'){ echo '<ul>'; foreach($array[$index] as $item){ echo '<li>'; echo $item; if(isset($array[$item])){ listElements($array,$item); } echo '</li>'; } echo '</ul>'; } listElements($array); Also, by doing this in a recursive manner, you don't limit yourself with regard to the depth of the list.
  10. Which is almost certainly a bad way to do it. If you use a big image and "resize" it with the img tag's attributes, then it'll still use just as much bandwidth as the big image and still take just as long to load. Vivid Lust, why don't you want to use getImageSize()?
  11. They appear to be MS 'smart' quotes. Somewhere along the line, something got typed in Word. In any case, this should really be over in php help
  12. I'm unsure about the locale settings MySQL offers, but i'm guessing that if you have a comma as your decimal separator then you're storing these values as a varchar or similar? You should be using a decimal field and formatting for output at the end.
  13. Hold up? The above code is the working bit to insert things into the database, but your having issues with the other end and getting items from it? If so you might like to check out this tutorial, which covers all the basics: http://www.phpfreaks.com/tutorial/php-basic-database-handling
  14. 1.) This really doesn't have an awful lot to do with maths. Please try and post in the correct section. 2.) Any chance of you using some tags around your code please? It makes it very difficult to read your code otherwise. 3.) You've posted a lot of code. How about narrowing it down to the relevant part? Is there a section where you're having real problems? What exactly have you tried after all the effort you've said you put in?
  15. Are they in the same file? If so, you definitely need to be adding checks to ensure the form was submitted.
  16. Yeah, you cannot refer to an alias in the WHERE clause. Not entirely sure why. luca200's solution should work for you.
  17. This is more likely to be a PHP issue. I cannot see anything wrong with your code per-se. The only thing i can think of is that form submits to itself, and you're not checking to see if a form's actually been submitted and are attempting to insert everytime the page loads? Maybe it would help if we saw some more of your code.
  18. No. I'm afraid they created that website with a magic wand, which has unfortunately since been broken. It's therefore impossible to create something similar.
  19. If all you're looking to do is select unique entries, using GROUP BY would be more efficient. Not to mention less code.
  20. You shouldn't be attempting to access variables from outside the class like that. It totally ruins the point of OOP. If you must though, use (as you said) global variables: http://uk3.php.net/manual/en/language.variables.scope.php
  21. Not sure i follow...are you after a group by clause? SELECT comp_name FROM comp GROUP BY comp_name
  22. Ok. So you know how to make a checkbox ticked by default, right? You also know how to check to see if it was checked in the POST array, right? So...What do you think you need to do?
  23. Yes, php is a loose language. And yes, the above will work. But only if notices are turned off. Which you cannot guarantee.
  24. Ken, you really ought to be checking to see if it was set first.
×
×
  • 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.