Jump to content

redsmurph

Members
  • Posts

    35
  • Joined

  • Last visited

Everything posted by redsmurph

  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
  14. I already know to check the user agent, so the question is what to check for? There must be a white list or black list of user agents I could check against, right? A white list might be as good, provided it's updated on a daily basis, as I would otherwise miss accesses from the many new mobile phones coming out every day. I'm using WURFL for device characteristics, and possibly that would work for this too, counting only user agents WURFL knows about, as it also contains PC browsers. As all media file upload sites need this, I'd be surprised if there's no tried and true solution around. Cheers, Anders
  15. I've developed a file upload service of sorts. Think TwitPic, TwitVid and Twaud combined and it's not that far off. I need to determine which content pages are most viewed. Right now I just count each and every page request, so... The problem I run into (of course) is that also agent/bot requests are counted, and for some reason search engines (or other services) are very keen on accessing pages with many pictures on them, so such accesses can easily "overload" and make the access counting quite skewed. Is there a black list of search engine user agents I could deploy, or is there a more generic way of knowing whether I get a request from a search engine rather than a user? I still want the content pages indexed by search engines, so they shouldn't become "invisible" to them, yet I need to be able to determine what accesses are from primarily real users. There's no need to log in to see the content, so I can't use that as a differentiator. I suspect there are also image grabbing agents accessing my pages, and honestly they could be shut out completely. Thanks in advance, Anders
  16. Articles normally contain very few line breaks (\n) as each paragraph is technically one line of text. Hence you can handle line breaks the same way as other characters. One thing you might want to do though is to secure that the last word of the page is not cut in half. Especially if you use UTF-8 this can otherwise create garbage characters. In that case I recommend setting mbstring.func_overload = 7. If you want to show full words, then you have to search for the last separator (" " would suffice) in reverse and in the string segment you are going to show, and shorten the string accordingly and then compensate for that "loss" on the next page.
  17. Search for 'php gd' and you'll get all the info you need. GD supports rendering of images without saving them as files.
  18. If you suspect something like that (or even if you don't), just call the following and you'll know. Saves a lot of time. var_dump($_POST); var_dump($_GET);
  19. Each list provides different data so you need separate names, like bday_year, bday_month, bday_day, and then $birthday = $_POST['bday_year'] . "-" . $_POST['bday_month'] . "-" . $_POST['bday_day']; Or whatever date syntax you want to have.
  20. Yes, I meant file-based session variables. That's the default, and that's what PHP Fog doesn't allow. I found this that should help, but I still have to write the code of course: session_set_save_handler('_open', '_close', '_read', '_write', '_destroy', '_clean'); Or is there a simpler way?
  21. Please state the complete query string (the completed $query in sqlinsert). I suspect the table somehow doesn't match what you try to insert.
  22. @Mahngiel: That was what my advice was about: read rows with the same ZIP code, merge ZIP lines to one (where all cities are put in one column as a JSON array or whatever), store merged row in a new table. Rinse and repeat.
×
×
  • 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.