Jump to content

DaveyK

Members
  • Posts

    289
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by DaveyK

  1. so what error is displayed then?
  2. From php.net: "Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP. It is a very common error to read code with include, or require, functions, or another file access function, and have spaces or empty lines that are output before header() is called. The same problem exists when using a single PHP/HTML file." The header() is probably causing your first problem.
  3. No I know that was possible, just never really know what was "Best practise". AS for the UNIX, im sending the UNIX from sql->php-> js so that the JS can use it to show real-time times (IE: 1min ago) However, I will considering using the setup as psycho suggested. Thanks!
  4. In this case we are using backbone.js so almost everything is fluid js. Returning UNIX just made sense for real-time but, as I said, I have very little experience with this. I will consider timestamp next time, thanks very much for the advice
  5. haha. have you tried echoing (var_dump()) all the correct variables from your form before you actually send them in the sql?
  6. yeah. Thanks a bunch guys!
  7. 1. For encrypting password you can use a combination or sha1() and md5() in any random order, that is quick but a hacker can still break it. A more secure method would be to use crypt(), say if you use a blowfish algorythm it would be nearly impossible for a hacker to retrieve it (even with super computers). 2. I dont know dreamweaver, never used it. However, what I know from SQL injection is that users sometimes use their $_POST info directly into a query ("INSERT INTO (...) VALUES ('.$_POST['var']"). Never ever do that. People can modify that POST and blow your stuff up. a more secure method would be to use htmlspecialchars() or mysql_real_escape_string() like such $name = htmlspecialchar($name); It helps. 3. Considering the account number is unique, adding the company name appears to be a little bit redundant if you ask me. However, if it makes you feel better, why not? Also, I am not a very experienced developer so I may be wrong. If so, anyone please correct me.
  8. DESCRIBE `views` | Field | Type | Null | Key | Default | Extra ------------------------------------------------------ | view_id | int(11) | NO | PRI | NULL | auto_increment | viewer_id | int(11)| NO| | NULL | | location_id | int(11) | NO | | NULL | | location_type | int(11) | NO | | NULL | | time | int(11) | NO | | NULL | EDIT: Sorry about the mess before! EDIT2: WHen inserting `time` into the table I use the mySQL UNIX_TIMESTAMP() function to insert the time.
  9. Interesting, that is actually pretty great. We are currently using <?php $since_yesterday = $time - 86400; $sql = "SELECT `location_id`, `location_type`, COUNT(`view_id`) as `total_views`, SUM(`time` > {$since_yesterday}) as `last_day_views` FROM `views` GROUP BY `location_id`, `location_type`"; ?> which appears to work nicely. However, my question remains:
  10. Hey psycho... well, that just blew my mind. In simplicity. Oh well, I have a lot to learn. Anyway, it does not quite work yet. I think I understand the DATE_SUB thing (I admint, I just looked it up!) but not matter what I try, it seems to return 0. Is this because the `view_date` (as you use it) is actually `time` (a UNIX_TIMESTAMP). So my two questions here are: 1. does this fail because we are storing unix_timestamps rather than actual dates 2. should we be using dates rather than unix_timestamps? We very much appreciate your help!
  11. Hey guys, I am also working on the same project and I have tried numerous options for the query (UNION, mulitple SELECTs inside the FROM and a couple of JOINs). Allow me to explain. I am not a really good SQL programmer or anything so please bare with us. We are tracking page views inside a table: Views View_id (AI) viewer_id (INT) location_id (INT) location_type (INT) time (INT)(UNIX_TIMESTAMP) the View_id is obv the unqiue key in this table. Tje viewer_id is the id of the user that viewed the page, or 0 for guests. the location id is the ID of the location displayed, but since we have several types of locations (say, 6 different types), I chose to store the type also instead of using 6 different tables. so the combination of location_id and location_type is important, thought (in this table) obviously not unique. Regardless, the result we would want is(I am most familiar with php arrays so); [0] =>( [location_id] => 1, [location_type] => 1, [total_views] => 89, [views_since_yesterday] => 60 ), [1] =>( [location_id] => 1, [location_type] => 3, [total_views] => 140, [views_since_yesterday] => 10 ), [2] =>( [location_id] => 2, [location_type] => 4, [total_views] => 200, [views_since_yesterday] => 9 ) I hope I am getting the point accross here. Its supposed to be something of a "Trending Locations" kind of thing. I'm sorry for the confusion before! @mikosiko - I have no idea what you just wrote... But thanks anyway!
×
×
  • 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.