Jump to content

GingerRobot

Staff Alumni
  • Posts

    4,082
  • Joined

  • Last visited

Everything posted by GingerRobot

  1. GingerRobot

    hobby?

    Just for a hobby really. Unfortunately i don't have the time to do any freelancing, otherwise i could make some money out of this hobby.
  2. Nobody contradicted that statement, and everybody seems to have been replying as if it is true, so I did the same. I was under the impression that nearly everyone had contradicted that statement, since the possible implimentation will be different to the goto of other languages and wouldn't be called goto.
  3. Did you actually bother to read the previous posts? Evidently not.
  4. Fair enough. My preferred method for this sort of thing is a two dimensional array. The first element being the parent node. See this 'one i made earlier', which was for a nested menu: <?php function menu($menu,$index='Parent'){ echo '<ul>'; foreach($menu[$index] as $k => $v){ echo "<li><a href='$v'>$k</a></li>"; if(is_array($menu[$k])){ menu($menu,$k); } } echo '</ul>'; } $menu = array(); $menu["Parent"]["Home"] = "/index.php"; $menu["Parent"]["Contact Us"] = "/contactus.php"; $menu["Parent"]["Members"] = "/members/index.php"; $menu["Home"]["About"] = "/about.php"; $menu["Contact Us"]["Live Chat"] = "/chat/index.php"; $menu["Live Chat"]["Live Help"] = "/chat/connected.php"; $menu["Contact Us"]["Email"] = "/emailform.php"; menu($menu); ?> Obviously its not quite what you need, but if i were doing it i would be looking to transform the data into a similar array. Hope that helps. If you're still having problems tomorrow, ill post a better solution, but right now i'm off to bed.
  5. Is there any need to store the data in this format? Surely a simple 'account type' field would be more appropriate? I don't see this as being a complex tree stucture: surely there will be no deeper tree structure than as shown above? As in, there wont be a separate list under Tom, or under Dick etc. If you were to just store the account type, you could order by this, then by ID, and output the required list elements (Administrators, Users, Guests) when the account type changes. Would be a much easier approach.
  6. The strtotime() and date() functions are your friends here: <?php function listdates($startdate,$enddate,$format='Y-m-d'){ $date = strtotime($startdate);//convert to unix timestamp $enddate = strtotime($enddate); while($date <= $enddate){ echo date($format,$date)."<br /> \n"; $date += 60*60*24; } } listdates('2007-12-01','2007-12-05') ?>
  7. Since phones have predictive text, i dont think theres much of an issue in typing out words properly in text messages either - except the character limit as i said before. Completely agree with the points about grammar. It's pretty shocking. I think i've come to accept, and indeed sometimes use, a slightly less then perfect level of grammar on the internet, but the general level of grammar is appalling. My pet hate is the incorrect use of the apostrophe. Particularly in signs. It's really not that hard is it?
  8. I did use PHP 4 a while back when i was learning php and developing a game. Running php 5 on my local machine, and don't have any projects so thats all i use now.
  9. Yeah, i absolutely hate it. I 'spose i find myself using some of the common acronyms, but i do pretty much type everything out properly. Same goes for texts, though i do sometimes go back and shorten stuff to keep it all in one text - i don't want to pay for two!
  10. You need to close the string before the semi colon: $query = "INSERT INTO users (video_url) VALUES ('$path') WHERE username = 'test'";
  11. How does consititute a mis-reading of something?
  12. As will 'test' Can you show us the new code please?
  13. Except that there are only rougly 2.3*10^57 different MD5 hashes that is.
  14. Im afraid your conclusion is incorrect. <?php $str = 'text<moretext'; foreach(explode('<',$str) as $v){ echo $v.'<br />'; } ?> Produces exactly the same as: <?php $str = 'text < moretext'; foreach(explode('<',$str) as $v){ echo trim($v).'<br />'; } ?>
  15. Damn, i think i lent Barand my mind reader chip from my computer again. Perhaps showing us some sample text in $string might help? Oh, and perhaps defining 'as i expected' would be useful too.
  16. How can something be explicitly implicit? Oh, and cooldude, sometimes you really do need to restrain yourself with your clicking of the post button. Please.
  17. ob_start; workaround? You don't need output buffering. Yes, you cannot send headers after output to the browser without using output buffering, but starting a session and assigning session variables does not output anything to the browser.
  18. If you wanted to count the number of files in a particular folder and all sub folders, you'd need to use recursion. Here's a blue peter-esque one i made earlier <?php function no_of_files($dir){ $no_of_files=0; $handler = opendir($dir); while(false !== ($file = readdir($handler))){ if($file != '.' && $file != '..'){ if(is_dir($dir.'\\'.$file)){//if this is a directory, recall the function with the subdirectory defined $sub_dir = $dir.'\\'.$file; $no_of_files += no_of_files($sub_dir); }else{//is a file, so increase our counter $no_of_files++; } } } return $no_of_files; } echo no_of_files('C:\Documents and Settings\Ben\My Documents\My Music'); ?>
  19. I hate to say it, but you should get out more
  20. Presumably you have another field which contains the ID of the person they added? A simple or clause would do: $CountFriends = mysql_query("SELECT * FROM friendslist WHERE UserID='$UserID' OR otherfield='$UserID'") or die(mysql_error()); $TotalFriends = mysql_num_rows($CountFriends);
  21. That sounds like an awful lot of maintenance. Why would you want to do that? You'd be better off with a dynamic approach whereby you pass an ID or a username to the logged-in location, and load the appropriate content based on that variable.
  22. Whilst you could carry on with your current method, i suggest you use arrays. Since your code is long, ill just give a quick example: <?php if(isset($_POST['submit'])){ foreach($_POST['qty'] as $k => $v){ if(ctype_digit($v) && $v > 0){ echo 'The customer ordered '.$v.' units of the product with ID: '.$k.'<br />'; } } } ?> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <?php for($i=0;$i<5;$i++){ echo 'Quantity of product '.$i.' <input type="text" name="qty['.$i.']" /><br />'; } ?> <input type="submit" name="submit" value="Submit" /> </form> Take a look at how that works. Once you understand that, rewrite your current stuff to make use of arrays - it's much easier.
  23. Well, your query would generate an error. The call to date() would not be parsed, so your query would litterally be trying to place the text date('m-d-y') in your database. Also, you should always add an or die statement to your queries if you suspect a problem. Try: <?php mysql_query("INSERT INTO members (`username`, `password`, `paypalemail`, `ip`, `joined`, `money`) VALUES ('$usename', '$password_md5', '$paypalemail', '$ip', '".date('m-d-y')."', '0')") or die(mysql_error()); ?>
  24. Try: print '<a href="display.php?id='.$_SESSION['id'].'">$catname</a><br />'; Next time, give us the actual error message - dont just say theres 'something wrong' with it. Also, i suggest you change your foreach loop to: foreach($file as $Key => $Val){ $Data[$Key] = explode("|", $Val); $loop_id = $Data[$Key][1]; if($loop_id == $id){//each time the loop runs, check if it is the ID we are looking for if it is display the info $username = $Data[$Key][0]; $thumbid = $Data[$Key][2]; $title = $Data[$Key][3]; $desc = $Data[$Key][4]; $date = $Data[$Key][5]; //print out the information print $username; print $loop_id; print $thumbid; print $title; print $desc; print $date; break;//once found, we can exit out of our foreach loop } } Otherwise you'd be showing all the information regardless of the id. Oh, and finally, is there any reason why you're storing the id in a session? I don't suppose it'll be needed again after display.php, and it's already being passed to display.php in the URL, so its not really needed.
×
×
  • 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.