Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. $lines = file('path/to/file.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
  2. Yes, users can turn it off. In which they will always retrieve the page.
  3. How does it show up in your source? It's possible you set the wrong character set.
  4. In case you don't understand by what he means with environment(s): you have access to the php.ini to configure allow_short_tags. However for portability and ease it's best to use <?php as this is guaranteed to always work.
  5. Look into Zend_Translate at http://framework.zend.com/manual/en/zend.translate.html
  6. A little example: if($user->login($_POST['username'], $_POST['password'])) { if ($user->isAdministrator()) { header('Location: ..'); exit(0); } else { header('Location: ..'); exit(0); } } You would do well to separate your DB from your User class. And since when is an Array of products part of a User? Shouldn't these be in your Cart class? PS Did you or your teacher write class User extends ConnectToDb? If so, then ask him since when do models save state?
  7. if (isset($_SERVER['HTTP_REFERER'])) { $query = array(); parse_str(parse_url($_SERVER['HTTP_REFERER'], PHP_URL_QUERY), $query); print $query['q']; }
  8. That depends on how you model your application. I, for one always have a User object with the default name being Guest and rights set accordingly. So I would just write: <?php echo 'Welcome, ', $this->memberName; ?>
  9. $form->addElement('Checkbox', 'id', array('isArray' => true)); $form->addElement('Text', 'text', array('isArray' => true));
  10. Indeed this puts the cache on the client instead on the server. So, when a client asks for a particular page which has not been changed since his lasts visit you return a "304 Not Modified" header and the browser will use the cached page.
  11. I also found: http://mobile.tutsplus.com/tutorials/html5/html5-apps-positioning-with-geolocation/ I think I will go with this one as the previous exposes too many global variables. I can't believe there is no decent JS API available?
  12. I think I got it http://code.google.com/p/geo-location-javascript/
  13. Hi does anyone know how you can get the coordinates from a mobile device like blackberry, iphone, ..? I've looked through Google and found http://stackoverflow.com/questions/1058880/can-iphone-send-gps-coordinates-to-a-website-painlessly However this is for Safari only, what browser do these phones use? Are there any frameworks that hide this complexity? Thx
  14. You are calculating the number of pages inside the loop get them out as no matter how many times you calculate it if you have 6 items as a result and only show 5 on each then you still have 2 pages.
  15. Post it, so others who may stumble upon the same problem can learn from your experience.
  16. What is filename.php and where does input come from?
  17. pdo is a php extension. I am well-aware of that, but this was moved here and was originally posted in the PHP Coding Help so I still believe he wants to use PHP as some kind of middle-layer between his DB and his VB.NET program as he can't use ODBC somehow...
  18. http://ferruh.mavituna.com/sql-injection-cheatsheet-oku/ -- Here's a full list of things that can do harm. I can already imagine how that code looks like.
  19. You paid for this? -> $sqcm="select * from cms_tb where cid='".$_REQUEST['id']."'"; leaves you completely open to SQL injection attacks.
  20. Fix your images, they show a very poor quality.
  21. From your description, Image looks like a plugin to your Uploader class. Also separate HTML from your PHP, your uploader only needs to know the field and if it's an array. Your Uploader package should contain these classes at a minimum: Uploader -- The main uploader class Uploader_Abstract -- Façade for the actual upload process (final), does not define the methods in the _Interface Uploader_Interface -- defines the methods used by the Façade Uploader_File -- Representation of a uploaded File, allows for easy operations on a file (eg hasExtension(array('jpg', 'jpeg', ..)), isValid(), ..) Uploader_Plugin_Image -- Takes in a Uploader_File verifies its an image and performs resizing Uploader_Plugin_Upload -- performs the actual uploading and is auto-appended by the Uploader class on the upload() call Uploader_Plugin_Abstract -- Used to add more plugins in the future (eg PDF, Video, ..) As you can see it contains a Uploader_Plugin_Upload class which performs the actual uploading, this is to allow uploads of the original file and a thumbnail. $upload->addPlugin(new Uploader_Plugin_Upload('images')) ->addPlugin(new Uploader_Plugin_Image('50%')) ->addPlugin(new Uploader_Plugin_Upload('images/thumbnails')) ->upload('file', TRUE);
  22. No. Always use mysql_real_escape_string It's not because it was not entered by the user that it can't be harmful, it can still break your query.
  23. You can also go the Java way of course, for example: class Integer { private $value = 0; public function __construct($value) { $this->value = intval($value); } public static function parseInt($string) { return intval($string); } } $int = new Integer(5); $intie = Integer::parseInt($_GET['value']); class MyClass { public function __construct(Integer $int) {} }
×
×
  • 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.