Jump to content

redsmurph

Members
  • Posts

    35
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

redsmurph's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. A tried solution that works on the server side is WURFL. I use the database version. Nowadays you can determine at least display size via Javascript instead. WURFL provides much more than that though, e.g. supported media file formats etc. The issue with WURFL is that it's never up-to-date, as new mobile devices are released daily. The PHP library tries to find near matches if there's no exact user agent match, but it doesn't always find something comparable.
  2. POST is typically preferred: Not visible on the address bar, more data can be transferred, and required if you transfer files (via an input type=file field). There might be cases where document.forms["theForm"].submit(); is preferred too. I'll check that. Clearly it's needed if you want to address a certain form rather than the one the field is in.
  3. This is how I do it, usually. I don't know if the longer syntax would be preferable. <select name='whatever' onchange='this.form.submit()'>
  4. I read your code again, and it looks correct that $e is only set if the else section has fired and the insert is then only done if $e is set, but I suspect that mysql_query returns false. You have to test for that before calling mysql_num_rows, otherwise $e will be set even for an error. A remaining error is that you don't escape the strings in the insert. If an apostroph is in any of the strings you'll get an SQL error.
  5. Agreed, as she needs the comment count for all the users. If it had been only one user I would have gone for a separate call to start with so I get a working solution.
  6. You can't "fire" the PHP other than by making an HTTP request from Javascript or perform submit on a form. In your case I would suggest this: http://www.javascript-coder.com/javascript-form/javascript-form-submit.phtml PHP is used to perform the server-side tasks and content creation. Javascript is part of the content creation, hence is performed after PHP has done its bits.
  7. To make it simple, just make a new query just checking for the amount of comments for a certain user, as I imagine/hope you've tagged each comment with the user ID (user table row rather than user name preferably), and all comments are in one table. Not everything has to be done in a single SQL query.
  8. All PHP code has already run when Javascript scripts are performed, so you either have to make something happen on the page via Javascript (e.g. change the page appearance etc via DOM editing), or send data to a PHP script (and indirectly the database) using Ajax. What should happen on onchange?
  9. I tend to use a $page_title like so: $page_title = "Some nice page"; include 'header.php'; This then affects <title> some of the meta data and is also echoed as "<h1>" . htmlspecialchars($page_title) . "</h1>" If I don't set it, <title> become a generic site name, and no header title is shown for the page. Cheers
  10. The immediate benefit of not saving to a file is that you don't have to create unique file names (remember that a web site is always a multi-user application). A simple cache could though be implemented by saving images with the size included in the name somehow, like image1_300_300.png. That way you could easily test for it and grab it later. If it doesn't exist you generate the image in the right size and save it as mentioned. The problems I've found with controlling the size in CSS are: - The browser still has to download the full size file. Not a good choice if you access images via a mobile phone, especially if what you need is a tiny thumbnail picture. - Some browsers aren't good at resampling the image, causing artefacts. Admittedly it was way worse a few years ago. Cheers
  11. Do you have several fields with the same name? That doesn't work. Each field is unique and needs its own name that will then be posted. Hence, you should neither loop on POST variables. They are atomic strings. Also, you don't escape the strings in the SQL query. Never user the "$variable" syntax for that reason. What if some text contains apostroph? Never assume that strings are escaped beforehand (deprecated from PHP). Sorry, but you need to read documentation on how PHP and SQL work. Cheers
  12. You set $error_mail_taken, but wat do you do then? You have to test for it and take action, not continue on to make an insert if the e-mail address is already in the database.
  13. Thanks mate. It admittedly looks a bit like WURFL, even though I understand the intent is a bit different. Anders
×
×
  • 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.