Jump to content
Larry Ullman's Book Forums

Antonio Conte

  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Antonio Conte

  1. It could very well be, yes. I'm betting you'll find libraries already written for handling image uploads, so that'll spare you a lot of hours of development time. The same applies to other frameworks, which is one of the reasons you'd maybe want to use one. The drawback is generally time spent learning how to use the framework, but a book will help speed that up. There's no absolute truth here, so spend time doing some research and make up your mind that way. Playing with YII or another framework for a couple of days might pay off in the end.
  2. Your last thought is the right one. This is a one-to-many relationship that needs an table like employeesDeptartments. Larry writes about this in the sub-chapter starting at page 109. (Or thereabout - Larry has released lots of versions so far.)
  3. To add detail, PHP has a series of global arrays for HTTP request. $_POST is filled with POST data, $_GET with GET and $_REQUEST is a combination of them both. $_REQUEST is thus the least explicit of them of them all, and that's why you need to check if the request method is POST first. When you deal with just POST request, ($_POST) you already know that. It is therefor considered "cleaner" or more specific.
  4. The first tip to give you is to download an IDE with PHP support. That will highlight errors in your script for you, provide auto completion of functions as you type, and other nice things. A lot of them are free to. Check out one of the following: - Eclipse - Netbeans to your problem. Undefined variable is not really a constant. That's an error message. It'll happen if you try to use a not previously declared variable in a structure which requires that. In simpler terms, if you feed a variable that does not exist to an if statement, a function or similar, you'll get that error messa
  5. That is almost correct. The mail function takes a total of 5 params, where the last to is optional. It basically has this format: mail ( $mailTo, $subject, $message, $headers, $params ) In your case, I would alter it to something like this: // Set from address $from = "me@myisp.co.uk"; // Assign subject $user = isset($_SESSION['uaname']) ? $_SESSION['uaname'] : ""; $subject = "Posting added by " . $user; // Build here message $message = "very long message"; $message = wordwrap($message, 70, "\r\n", true); // Create header $headers = 'To:'. $mailto . PHP_EOL; $headers.= 'From:' . $mailf
  6. Yes, they are case sensitive. The easiest way to avoid problems with that is to download JS syntax highlighting to your IDE/Programming software, install Firebug in Firefox to catch any errors that way, to check your code using something like Jsbin.com (built in syntax highlighting) or by using jslint.com. Glad you solved it. Nice work.
  7. You do have some pitfalls here. The last parameter you add ("From: $uname") does: 1.) Not exists. Optional headers, your $messageproper, is the last valid param you can specify. 2.) Is not a valid From address. According to RFC 2047, you need to specify it using one of the following formats: user@example.com user@example.com, anotheruser@example.com User <user@example.com> User <user@example.com>, Another User <anotheruser@example.com> Optional headers. You cannot apply headers the way you are doing it. The "From:" header should be set either here or in your php.ini,
  8. Ok. I have downloaded and checked the code now. Calculator.html should work without Calculator.php. There might be several reasons why this is not the case, thought. 1. Make sure you include the jQuery framework. - Basicly make sure the "js" folder is located at the same path as Calculator.html. The easiest way to check this is to view the document source in Firefox (right click and find view source) and try to click the link to jquery.js. If that doesn't work, your browser won't be able to find the JS file neither. Move the folder or change your path until it works.2 2. Make sure you
  9. Looks like I took a wrong guess here. Will post more later today, but you basically get a 404 as calculate.php does not exists.
  10. You are correct in most cases, but when it comes to Ajax request, you need the PHP file to get the correct response from your request. This is not a browser issue, (most likely) and I would bet you'd get the same response using Opera, Chrome or Safari too.
  11. Keep in mind most things in PHP and MySQL acts as a String even though the value is of the integer type. Try typecasting or parsing the value to an integer before anything else. Try something along the lines of... $row = mysqli_fetch_array($result, $dbc); $_SESSION['id'] = (int) $row['user_id'];
  12. My tip would be you need to use one of the commands listed. Try adding parse or run after your phpdoc command.
  13. Sometimes, I thank god I'm on a provider that does this kinda stuff for me. I had to install some locals a couple of months ago, and only had to snap my fingers! (And write an email) Good work solving this one.
  14. Nice solution. You write some really good code, Edward. The only thing I don't get is the array in your method? Why not do simple String concatenation instead of imploding an array in the end? My reasoning for adding exception handling is more about my Java background. If you have uncaught exceptions in Java, your programs will crash, so it's become something of a habit. I tend to always catch exceptions, even when it's not strictly needed. Thanks for the nice words about the site. The site is pretty much finished, and we will remove dummy data and start advertising the system quite soon.
  15. Glad you worked that one out. I did something very similar to you with a time range difference function, but with conjugations for the human-readable output. That means 1 hour - 2 hours, 1 second, 2 seconds, etc. I also added different output depending on how much time is remaining. It'll return days, hours, minutes or minutes and seconds when time < 10 min. I added a small gist here for you: https://gist.github.com/thomaslarsson/6029616 The class is not really good code by any stretch of the imagination, but it does the trick for me. Would love to see your solution for this too.
  16. Glad you solved it and thanks for the reassurance. Nice way to solve the problem btw. Clean, simple solution. I like it.
  17. Well. You laugh of me for not solving your problem in 15 minutes and you most likely called me "Dr." sarcastically. Why shouldn't I take offense to that? I HAVE given you a way to handle the functionality you describe, but most likely YOU can implement it way faster than me. It's as simple as that you know YII — I don't... You can't expect me to pull a fully functional implementation of this out of my ass on the spot. 1. Functionality goes into your extended base model 2. Set a protected flag property in the base model to turn auto timestamps on and off. 3. Write a protected method like
  18. What's with the attitude? You ask a question, get some possible solutions, turn them down and ridicule me? I'm not a YII master an has never pretended to be. What's your problem?
  19. Then just format the DateTime object like a timestamp? Not really a problem.
  20. If everything else fails, you could build a solution into your base model. Hook into something like the afterSave filter (or what it is called) and do a manual update using a formated DateTime object.
  21. The preferred option is generally composer now. Pear is a piece of garbage, and you can often find alternatives. I did a quick search for form builders on github, and found one with potential. It should do pretty much the same as Quickform2, without knowing exactly what that did. Er du norsk forresten?
  22. I like CodeIgniter's documentation too, but I find it a little too less concise some of the time. It's hard to strike the perfect balance for everyone, I guess. I don't really have more to suggest. To exaggerate, I woke up one day and it all suddenly made sense. I guess it's one of those stepping-stones kind of thing where you reach a certain level of understatement, and it's beginning to makes sense from that point on. Good luck moving forward though. Maybe someone have something else to add?
  23. This problem is related to packages and your include path. As you see from your error message, the file does not exists at your include_path. When you require/include files, PHP will check several places for that file if it's not found. When it can't find QuickForm2.php inside the folder named "HTML", it'll then check your include path. That's why you get that message there. If you turn on "view hidden files" on your computer, go do your C drive, then navigate through the folders /usr /local /pear /share /pear, that's where you computer expects the Pear package to be downloaded at. You mig
  24. Reading documentation and manuals are horrible, but you get used to it after a while. One trick is to ignore all explanations and look at input params, return values and examples first. Knowing data types and structures are often also important. You notice the manual type hinted the first param as a "callable" in array_map? The type text is also a link, so looking at that would possibly make your life simpler. Doing such cross-referencing is very important. Btw. The PHP manual is horrible compared to that of some other languages. I hope they fix a lot of that with the recent improvements o
  • Create New...