Jump to content

allenskd

Members
  • Posts

    50
  • Joined

  • Last visited

    Never

Everything posted by allenskd

  1. To do a foreach you must know the data residing in your arrays therefore you need to start var_dump()ing your array to know the structure. foreach iterates an array, iterates = lets say there are 8 keys with values stored in an array so foreach goes from 0 to 7 (do note that arrays always starts at 0 unless its a custom one) supposing we have $array = array('1','2','3','4'); //The count would be 3 var_dump($array); in an array a key starts with zero (yes I'm repeating myself) So, imagine this 0 = 1 1 = 2 2 = 3 3 = 4 Now when we want to do a foreach foreach($array as $key => $value) { // foreach is a loop that will stop at the end of an array echo "Key: ".$key ".PHP_EOL; echo "Value: ".$value."<br />".PHP_EOL; }
  2. Hello My name is David González (no speedy gonzalez , and no I'm not mexican either). Anyways, I live in Puerto Rico, the island of corruption. I'm 20, turning 21 this July 12. I've started learning PHP last 2004-2005 and so on. Where I also met Daniel0 but I forgot already how we met. All I remember was that I typed like an idiot "hw u doin, lolz did u see tat! omgwtfbbq!" or something like that. Well, also on that time I picked HTML, CSS and a bit of MySQL. Anyways, a few years passed and I still had Daniel on MSN I don't remember what I said to him but registered into this forum which I use to keep shaping my PHP and well other things (eventually) and join other discussions. Eventually I regained my lost interest in programming and got back in shape to continue learning PHP best practices, solutions and best interest in application design. From there I picked Java and today just started dabbling with C# with Mono. OS I use is archlinux, I'm no windows hater either(or microsoft), just getting experience. The IDE I use is netbeans 6.7 (btw do people keep saying, "hey, 1337 people use notepads, n00b!"? :|) Personal life: Social life == . I love reading books, about to finish The Book Thief to start Dry Ice. Favorite bands: Cranberries, Dream Theater, Iron Maiden, Metallica *to be honest, just the S&M release :x*. I have a dog named brigand which sometimes I feel like kicking for crapping the floor ! Favorite series: House, Supernatural, Fringe, True Blood <Whine> Still kicking myself for joining a sucky institution that could resemble a school in a third world. I have learned almost nothing. Last semester was supposed to be "introduction to web applications"," introduction to application design". We picked up flowcharting, ok. The professor gave the shittiest lesson ever, and tried to cover the lesson within 3 days. Now, there wouldn't be much problem, except SHE didn't know how to explain. Every time she started explaining somehow sentence jumped to another unrelated sentence. Well, it'll drop it here lol, else it'll never end.. besides, we went into a Strike against the institution administration afterwards... blah blah </Whine> Favorite beverage: Heineken Sorry if there are some grammar errors, spanish here
  3. Really, the time it doesn't bother me that much but using that thing seems more counterproductive. It's a frame, I think, but to build applications on top of it doesn't sound like a pretty idea. I look through the PDF and it looked more like a sales man talking. complex, weird named directory structures. have you heard of KISS?
  4. Drupal gave me some trouble personally, its the annoying learning curve it takes a while to get familiar on how it works before you start developing a module or theme. I mostly use wordpress, Joomla! (yes I have used joomla but only to do some theming work, not really that hard to create themes) There is also SilverStripe, haven't used it but seems very attractive.. sadly it uses a template engine.. (just had a deja vu.. ) as for coding your own CMS, it's just the easy way out. It's okay to learn how to create a CMS but if you don't know much about security it can turn into the recipe for disaster.
  5. Well, you could check php.net/chown and try, but if it change... that's really a bad sign. You could also build an interface with your script to manage the files and continue managing them. Or you can log in to your SSH and chown them
  6. It's probably because Apache is running as root (or different group/user), so it creates the file that it only can manage. So you can't directly use ftp but still can manage it using your script, http://php.net/unlink or SSH to chown the file Then again thats as far as I get, lets see if other users have a different way to manage this
  7. I started looking at the topics name at PHP Help... it reminds me when I was browsing 4Chan site that was the day I lost half of my braincells :[ *facepalm* Well, true enough you could either force the users to learn how to ask questions... then again.. it's one scary thought. Of course you could also do CV's suggestion of "after post" that is to direct it to the search then if the post doesn't exist (which probably will do) create a new one which is probably better than having a real-time lookup. Now, truth is that not many people will know how to ask because they are new to PHP. Yet, there will be people once in a while that comes asking specific questions (paypal subscriptions... how to do X thing, i want to create X... ) if the javascript is tried, while the user writes the post title they become more aware of how irrelevant is their topic, so it is safe to say that they might attempt to rewrite the topic to see what results they get. Or not. It's hard to determine how many users will become aware
  8. What does $myusername carries? it's nowhere in the code so I assume thats the problem
  9. hmm.. I wonder if they are going to have a splash saying "Google OS Beta" :| Like corbin I also wonder how the GUI would look.. I just hope they don't take google's "web design" as inspiration.. Besides that, I wonder what default software will it ship(for audio, text editor etc), of course google chrome will probably be the main browser.
  10. You must attribute the column to ZEROFILL in phpmyadmin it would be UNSIGNED ZEROFILL
  11. well... you could start by adding a dot.. curl_setopt($ch, CURLOPT_URL, 'http://quiver.outwar.com/trade.php?tradeWith=7200&addItem=6919211&addHash='.$hash);
  12. Well, I don't know who decides these things anyway (site and forum features/updates) lol I'm already heartbroken and probably will cry at night but but I know... that deep inside... there is a kind soul (coughs blood) Anyway, well, the idea is there, just needs support and approval... *goes to overdose with valium and prozac*
  13. of course Oh well, was worth a try to mention, alright
  14. Hello! This is a feature suggestion for the boards. I don't know if you have been in ubuntuforums, google groups, or stackoverflow that features a set of relevant topics using the keywords typed in the title name It would help quite a lot to keep down redundant questions made in PHP Help forum imho (or maybe other forums) See attachment for example, taken from stackoverflow [attachment deleted by admin]
  15. I have done it once like a year ago but I forgot lol check out this thread should help you grasp how to do it http://www.phpfreaks.com/forums/index.php/topic,257920.0.html
  16. well, I'm certain it can be done, you could dynamically call each photo outside the public_html folder and output its content. like, file read the content, change the header() to the image's mime type so the browser knows what data is being outputted. Or, you can just simply put a .htaccess file and make it strict that no one can see the insides of the folder. which is another solution
  17. I don't know if this was either directed to 448191 or me. If it was to me then let me tell you that having that thought makes you pretty arrogant instead of being more open. Sure, I'm not a genious, and I don't believe there is a programming genius anywhere. It takes a great amount of practice and comprehension to reach a decent skill. If I'm lacking, then why do you see me here? I won't pretend I know everything and well I'm here to learn what the community members offer. As for my assumption, it just that.. even if I protect the keys, it will inevitable be global. I'm starting to believe there is a secret fanbase for registry singletons..
  18. You kind of answered you own question Yes, there are two ways to delete accounts, either by checking the timestamps or identifying a boolean in a column (e.x "activated") so when you look up in the database, gather the "activated" column and the timestamped column and let logic do the rest Now, if you want it to automatically check every.. 1 hour, look up for Cron Jobs
  19. If you mixed my solution with ignace's solution it will not work since he hides the ID in a hidden input so it can be seen in $_POST later on, *actually his way is a bit more secure, but never let your guard down*. The solution I did was to attach the ID into the FORMs action so when you submitted the info, it would go to http://blahblah.com/updatequest.php?id=X Anyway, just do us a favor a var_dump these variables updaterequest.php <?php $con = mysql_connect("localhost","-----","---"); $id = mysql_real_escape_string($_GET['id']); ## Remove later echo "ID from $_POST "; var_dump($_POST['id'])."<br />".PHP_EOL; echo "ID from $_GET "; var_dump($_GET['id'])."<br />".PHP_EOL; # Remove later if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("-----", $con); $sql="UPDATE quests SET `questname` = '$_POST[questname]', `description` = '$_POST[description]', `difficulty` = '$_POST[difficulty]',`length` = '$_POST[length]',`reqs` = '$_POST[reqs]', `unlocked` = '$_POST[unlocked]',`items` = '$_POST[items]', `qp` = '$_POST[qp]', `reward` = '$_POST[reward]',`start` = '$_POST[start]',`instructions` = '$_POST[instructions]' WHERE `id` = '$id'"; if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<font color='#FFFFFF' size='2'>1 record updated</font>"; mysql_close($con) ?> Another tip(s), really, put some quotes inside those brackets, and htmlspecialchars the data. and take a look at Daniel's Stop using "or die()"
  20. Been reading articles and so on about patterns, visiting wikipedia, checking on solutions to apply on my first application (I'm still vigilant on not overkilling the application with the overuse of patterns) Now, I don't really plan to remove the Registry Singleton, it's still good to carry common application data but what I want to avoid the most is making the application to rely heavily on the Registry. I don't want users to see available objects they are never going to use in the registry. In fact if I can help it I don't want objects at all to be loaded onto the registry at first instance. So far, the base controller (abstract) gathers the database layer, session layer, views layer which should suffice for now for simple extensions(applications)(methinks) What I want to avoid is people loading lets say, the Router class into the registry because it wouldn't make sense. (at least to me). (which is also somewhat 448191 mentioned but I'm making a few exceptions because not everything needs to be loaded onto the controller) About the models, that's actually a great idea, models were actually out of my thoughts process because I was absorbed reading some patterns stuff, etc etc. I've been refactoring some code and folder structures which so far I don't see any problems. Time for some whining , man it's a bit tough to grasp, but better do it now than never... if the design I create is correct then I don't have to worry about future upgrades. </whine> Another reason I want to avoid the use of registry singleton is because I plan to use PHPUnit. It's also something new I have never used so I drive some tests to ensure my work is behaving like it should. So far I've read registry singleton makes unit testing a bit harder. Is this correct?
  21. I just noticed my own error, needed to look back twice in updaterequest.php change it back the POST to GET and try <form action="updatequest.php?id=<?php echo $id; ?>" method="post"> (or echo the id however you want it when you submit it leads to updaterequest.php URL that means there is never an ID appended right?
  22. Hello! First in your script, make your the request is from a POST if(isset($_POST['NameOfTheSubmitButton'])) { ... code ... } Anyway I noticed in updaterequest.php $id = mysql_real_escape_string($_GET['id']); Which I believe should be $id = mysql_real_escape_string($_POST['id']); var_dump the POSTS and GETS, should help you to identify these problems (on each input/submit)
  23. Hello Thanks answering I'm still submerging myself into design patterns and application design so yea I'm a bit new. I'll be looking up those patterns, the PHP world seems to be evolving more oriented than ever so I don't want to be left behind It does make sense, a little, but I'm getting there. I'll try it today and come back if I don't understand a pattern
  24. autoloading... do'h! (and type hinting) Thanks for the solution on the registry keys, that was also on my mind, couldn't help to think that if users started writing extensions they would use the explicit option which would be annoying.
  25. Hello, I just finished reading the post about 10 Signs of Crappy PHP Software by John Kleijn This is an overview! I'm on my way to create a message board, because I'm tired of phpBB, smf, vanilla. in coding terms they don't offer much flexibility, except Vanilla, I only opened the code once, after that I dared not to. So I set the main priority of my forum is to be mostly flexible and be able to create extensions painlessly, not to mention the template system which is most painful. I'm half way implementing the MVC design with URL "rails-style" routing. Now, some of you might say, why not use an existing framework? pretty simple, it's not because "i don't trust their code" it's because I want to learn and to feel more accomplished that I understood and implemented it. Anyway! To my true post: I just wrote a Registry singleton, one of the issues that the post mentions is that the data is still available to everyone and one can change variable to anything. I did keep that in thought so my registry is a bit more strict with the aim of stability. Here is the code In simple terms: If the key is explicit, it cannot be removed to modify again, most of what the registry currently carries is, systempath, templatepath, extensionpath, BaseURL, Database. What should I keep in mind to avoid the overuse of singleton patterns when I need an object?
×
×
  • 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.