Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. We generally adhere to plurals (UsersController in combination with .htaccess you can create users/ignace) Now back to MVC. You can create one controller for each page in your website or create one controller that handles multiple related actions: class EditPageController extends Controller { public function __construct(.. } //or class PagesController extends Controller { public function addAction() {} public function editAction() {} } A good practice is to keep your controllers thin and your models fat. By this they mean that your controller should have nearly no logic while your models should have it all. This approach ensures software flexibility for example: class UsersController extends Controller { public function addAction() { if (UserRepository::add($this->getRequest())) { $this->getResponse()->redirect('/users'); } } } As you can see above my code knows nothing they don't know what sort of request they got for all they know I could have done something like: > index.php --controller users --action add --username ignace --email ignace@mail.com or POST http://domain.com/users/add username ignace email ignace@mail.com or .. The best thing you can do is write your software in such a way so that everyone knows only what they need to know and nothing more the same goes for your website. Depending on what sort of request you get your software may return plain/JSON/XML/HTML/XHTML I list HTML and XHTML separatly because through content negotiation you can decide wether the client browser supports XHTML. The same goes for language an american gets everything in english while a frenchmen gets everything in french while your application logic remains mostly the same for all requests (http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html).
  2. http://httpd.apache.org/docs/ This is all the tutorial you'll ever need.
  3. However if your code is distributed among many servers who are not hosted by you (which is why you would want to implement such functionality) will your customer or someone who they know that unlucky for you knows PHP code can easily alter your code so that authenticatkey() will always return true.
  4. So does Google. However you have to make the choose wether you want your files to be distributed (Git, Mercurial, ..) or centralized (CVS, SVN, ..). Most developers nowadays opt for distributed. Distributed version-control is also new which may explain the previous. Here's an article by smashing magazine that may help pick what you want: http://www.smashingmagazine.com/2008/09/18/the-top-7-open-source-version-control-systems/
  5. Your query failed. "'green eyes You were missing a ' Try to get in the habit of writing your query code like this: $statement = "INSERT INTO aliens_abduction (" . " first_name, last_name, when_it_happend, how_long," . " how_many, alien_description, what_they_did," . " fang_spotted, other, email" . ") VALUES (" . " 'firstname', 'lastname', '5 years ago', '2 years'," . " '7 aliens', 'green eyes', 'we talked'," . " 'yes', '', 'none@gmail.com'" . ")"; You were also missing an argument using this method you can spot this easily (the number of arguments per line equals the column names and the values: first_name, last_name, when_it_happend, how_long, 'firstname', 'lastname', '5 years ago', '2 years',
  6. You might wanna explain your problem as we are programmers not telepaths. If you want to receive help you need to help us. This means a clear explanation of the problem and properly indented code not some junk that might turn out to contain keywords of a certain programming language. The main reason you can't debug this yourself is because you can't read it anymore yourself.
  7. It's mysql_num_rows and not mysql_numrows add these lines to your script: error_reporting(E_ALL); ini_set('display_errors', 1); That is after the <?php
  8. Why don't you just put all images into images.domain.com? And link to them using: http://images.domain.com/image.jpg
  9. @rajiv I think Daniel already partially answered my question but what I actually wanted is that when I define a user function and the user gives a wrong format (array instead of string) then it would report that error instead of me writing: __FUNCTION__ expects parameter two to be string, gettype($variable) given. It's possible I think when using the SPL extension: function functionName(SplString $param1, SplString $param2)
  10. Read this article by Chris Shiflett: http://shiflett.org/articles/cross-site-request-forgeries
  11. Hi, I was wondering if it would be possible to use PHP's default error messages? I think this would be quit cool especially when it comes to type checking. Is this possible? And what do you think of such concept?
  12. wordpress.com allows you to create your own wordpress installation and registers a unique subdomain for you. your-username.wordpress.com http://wordpress.com/
  13. Provide some code if done correctly should have worked
  14. Add this to your PHP script (very first line): ini_set('short_open_tag', false);
  15. Try that {compiler:global,dynamic-typed}var
  16. What's in db.php? Where does $pilotid come from? We need more information to give you a solution
  17. Ajax altough cURL is your best option. However if this is to prevent fraud your software will be easily fooled as anyone with some PHP knowledge or JS can change those lines installing it nevertheless without you knowing it about.
  18. This might be what your looking for: INSERT INTO members (username, club) SELECT concat(upper(left(firstname, 1)), '. ', upper(substr(lastname, 0, 1)), substr(lastname, 1)), club_id FROM users One problem though: upper(substr(lastname, 0, 1)), substr(lastname, 1) This might be able to be simpler but I don't know a function that does something like ucfirst()
  19. I have found this page of O'Reilly always usefull http://www.oreillynet.com/pub/a/php/2002/12/05/one_time_URLs.html
  20. Joining two tables isn't much of a concern the cartesian product however is: the more rows it has to return the slower it will become. inner join != left join != right join an inner join will add two records to the result if they have a match left and right join will return all rows from the left or right table regardless if they have a match.
  21. It would help if you told us more about your problem and gave us more specifics, like where do you want to use it? If it's SQL then CV's solution will do but you will get one quote per author (last or first, not sure) If you want to create this in HTML using PHP then it would be something like: $result = mysql_query('SELECT * FROM quote ORDER BY author');// it's important to sort by author or the author's name will be duplicated across the page $author = ""; while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { if (0 === strcasecmp($author, $row['author'])) { echo '<h2>', $row['author'], '</h2>'; $author = $row['author']; } echo '<p>', $row['quote'], '</p>'; }
  22. First off it's none of your concerns wether or not I read the other replies I'm free to post whatever I want just like mods/admins are free to moderate my post/ban my ass. Mods/Admins not you Second your answer is off-topic and has no value for the OP which is worse? Third I said the same as oni-kun only simpler Fourth after a second look I realize I was confused and mysql_real_escape_string does actually nothing to the md5 string, my apologies (to the OP)
  23. Don't perform a real_escape_string on an md5 it will mess up the hash. Hashing it alone is sufficient.
  24. If you are looking for an object-database you may start by looking at this url http://en.wikipedia.org/wiki/List_of_object_database_management_systems
×
×
  • 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.