Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. $gender = (rand(1, 10) > 2) ? 'M' : 'F';
  2. The proper email compliant way of sending an html version of an email is to use mime encoding and send the html part as an attachment. It's a complicated process, and it's hard to do well without a thorough understanding of how multipart mime attachments work. For a simple link I would not suggest that. Just about every email client out there will find links and "linkify them" based on the inclusion of the http:// in the string. My advice is to just use a normal text email --- this is the safest and most standard way of doing it, and works with every mail client. Due to the many issues possible with html emails, many clients turn off features of html or disable them entirely, as old school as that sounds, but that is just the state of things these days given the proliferation of spam, tracking pixels, and all the html borne malware and viruses that target unsophisticated people. Just provide your link without any markup: http://www.yoursite.com/activeate.php ...etc. Do NOT add the anchor tag markup around it. You have to realize that how the email is handled in final presentation is 100% out of your control.
  3. You know how manually to assign a class to a tr right? The trick that was shown to you is to use the modulus operator dividing by 2. Do you know what a modulus does in math? Based on that trick, as you loop through the output of rows, you need to set the class either to be the even color or the odd color. The modulus with the ternary operator that wildteen showed is how most people accomplish this. The ternary operator is equivalent to an if-then-else, so based on the result of the modulus the variable is either going to be set to the 1st value if true, or the 2nd value if false. All you need to do is adapt the small piece of code that does the modulus and uses that in the ternary operator ( (bool) ? value if true : value if false ) so that it sets the variable $bgcolor to be the name of the odd or even class. All I can say at this point, is that if you have a specific question, or something specifically that you don't understand, then spell that out, preferably with code snippet included. We understand that you are new, but we also expect people to try things out and read, and do their own explorations, otherwise we're just writing code for people, and we already do enough of that in our day jobs
  4. This is part of using the MVC. Your code that handles data should be in the model classes. Many people also utilize an Object relational mapper (ORM) class. The two best known PHP ORM's are propel and doctrine. It is possible to integrate either one with zend framework. I'm sure if you google Zend Framework Doctrine you'll find a number of tutorials and examples.
  5. It actually isn't that directory though, the Current working directory is the one where the script is executing from. You store that path in the $thisdir variable. Then you append to that the /uploads and use that to scandir. However your current working directory is still $thisdir. So you can either change the CWD, or you can use the same method you used with scandir for is_dir and add the filename to the $thisdir."/uploads/" path when you pass the name to is_dir.
  6. Yeah the problem is with is_dir(). It operates relative to the cwd. So it's actually failing and returning false because it can not find any of the files or directories. Thus it never enters into the while(). You can append the path to the files, which depending on what you ultimately intend to do with them. Just to get a quick fix add a chdir() call: /*get the current directory*/ $thisdir = getcwd(); /*access the uploads folder*/ $dir = $thisdir.'/uploads'; /*read the files in the uploads folder*/ chdir($dir); $files = scandir($dir); /*select the last file sequentially*/ $lastfile = end($files); echo "$lastfile\n"; while (is_dir($lastfile)) { $lastfile = prev($files); echo "$lastfile\n"; } echo $lastfile;
  7. I had a bug in my code snippet at very least. It should have been while is_dir($lastfile).
  8. Hello George. I like your handle: Oldboy is a fantastic movie, that too few people see here because it's Korean. Welcome to phpf.
  9. That would not work if there are multiple directories. This would be a better approach: $lastfile = end($files); while (is_dir($files)) { $lastfile = prev($files); }
  10. Yes, that is what I am suggesting. Store a url and put the file on the filesystem or in one of the nosql systems I suggested. You can just store files on the filesystem of the server, but this might be a problem if your site ever needs to scale beyond a single server.
  11. Longblob is the right data type for doing this with mysql. Typically storing files inside the db is not the best solution in a web application, due to the overhead of having to receive the data and then pump it into the db via the client, as well as the fact that an rdbms offers very little functionality of any use on large blobs of data. People traditionally just store files on an nfs mounted filesystem for medium to large systems, or lately, have been using nosql solutions that are built for for storing files, and have the advantage of instrinsic distribution and scalability like mongodb's gridfs (see Tom's great intro to the topic http://www.phpfreaks.com/tutorial/an-introduction-to-php-and-mongodb) or membase: http://docs.couchbase.org/membase-getting-started-1.7/index.html
  12. Not really. The general idea is that all queries should eventually complete, so there's no reason to ever time them out. I've seen people cobble together a programmatic solution like this one: http://forge.mysql.com/tools/tool.php?id=106 which uses the mysql scheduler along with a stored proc that looks for queries that have been executing for "too long" and kill them.
  13. You didn't mention that. The way I read your original question, it seemd like you did a query and then couldn't understand why it would be using resources, but didn't mention you had a query that never actually finished executing. Yes, that query is called a cartesian product, and generates n1 * n2 rows. A very bad idea for sure, but not much of a cpu requirement although a huge use of temp table space. MySQL uses a thread per conneciton, so you see one core getting hammered. Memory use is based on your configuration. There are huge differences between innodb and myisam for example.
  14. Your fan runs when the computer is hot. MySQL has nothing to do with that. It's possible that you have gone over a memory limit, and you are now swapping a lot. 2 Gig is not a lot of memory these days. Depending on whatever else you're running, that would be my first guess.
  15. $this refers to the current object. $Home is an instance variable in that object, which is also in this case an object. printText() is a method defined in the class of the object $Home contains. I'm not sure why you arrived at this code or where you are using it -- but there are a often a number of ways to accomplish the same things in Oop. Judging from some of your prior code snippets, I guess that Home is an object of class Home() whatever that is.
  16. The obsession with frameworks is the same as the obsession with trying to not reinvent the wheel. It's really that simple.
  17. gizmola

    Junction

    Code looks ok to me, what results are you getting?
  18. There are a lot of different ways to accomplish MVC. There are also many other design patterns beyond MVC. There are entire philosophies that can be brought into play, for example, "Dependency Injection". The best frameworks and libraries tend to use established design patterns. Several that I know of (including Symfony 2) are highly focused on Dependency Injection.
  19. I have been involved in scores of group interviews over the years. My advice is simple: -Try and be as relaxed as possible. Make eye contact with everyone as much as possible. -Answer as honestly as you can, and be yourself. Don't get caught up worrying about what you think the right answer is. You have no idea about the agendas and hot buttons of the people involved. -Make sure you have some "good questions" about the company you're interviewing which shows that you are familiar with what they do, which gets them to talk about themselves and also shows you did your homework There are probably loaded questions that will lose you the job outright, but you won't know what they are. Overall, in my experience, people are looking for someone who is going to fit in, and be easy to work with, so the impression you really want to make is that you're confident without being arrogant, and yet still a team player who works well with others. You may get some of those questions that people love to ask like: "Tell me about a time you failed", or "What was a tough problem you had to face at work" and things of that nature, so it helps to rehearse a few of those, so you have a decent story to tell, that shows how you can make lemonade out of lemons. Just make sure that you remain positive throughout, and avoid any negative discussion about your past workplaces. You might have worked in hell for Sadam, but that's still a "great learning experience" where you learned a lot, and were able to achieve "this amazing success.." Short of giving programming tests and having people fail miserably, I find that people are looking to hire someone who will come in and make their life easier, and that's really what you want to have them feel about you. Good luck with the interview!
  20. If you don't know any better than you are certainly better off going with one of the top php frameworks. At present I feel it's a tossup between zend framework and symfony. There is a bit of transition going on with symfony as they are knee deep in a ground up rewrite for version 2.0. It's best to learn the rules, and then break them when you understand why. Of course if you're talking about a couple of form pages a framework is overkill, but for an intermediate developer who wants to learn about best practices frameworks are the way to go.
  21. Yeah it's a perk that a lot of companies have, as xylex verified for you. The other thing is, getting into Standford is not easy, but Google has such tight connections to them I'm just speculating that it would be a factor that would help bump you up the list.
  22. AyKay47, look into a testing tool like RegexCoach. You can verify your regex's do what you think they do without having to write up a test script.
  23. There is no better codec than H.264 right now for most web applications.
  24. Yeah if you wanted to try and get into Stanford, a job working at Google would be highly regarded by the admissions department I would think. However, the cost of going there is pretty crazy too, although Google might provide decent tuition reimbursement.
  25. I like your xyph, although we don't know what might be in the input string, that looks good, and doesn't care about position.
×
×
  • 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.