Jump to content

Jessica

Staff Alumni
  • Posts

    8,968
  • Joined

  • Last visited

  • Days Won

    41

Everything posted by Jessica

  1. There is one directory layer difference between these two: measured-response.com/leeds/study-info/demogstore.php measured-response.com/study-info/demogstore.php
  2. Notice what's missing?
  3. WHY do you want a whole new table? You should do some basic research on database design. What you just described isn't business logic, it's a workflow. Which is not useful to determine why you're trying to do something VERY BAD.
  4. probably need to do an if check before the for($i=1; $i<$daysBetween; $i++){ starts.
  5. Okay so now it's your turn to try to figure it out.
  6. By the way, I am by no means claiming this is the best way to do it - it's what I wrote in 10 minutes because it sounded like a fun challenge. Barand may have a much more sophisticated solution coming.
  7. If you have to ask that, it's pretty much proof you shouldn't be doing it. If you describe the business logic of what you're trying to do, we can help you with the programming logic.
  8. for($i=1; $i<$daysBetween; $i++){ $day++; if($day > 6){ $day = 0; } if($day != 0 && $day != 6){ $seconds+=(60*60*; } } Fix that section.
  9. Here's my fixed attempt: <?php function workTime($start, $end){ $endDayOfWeek = date('w', $end); if($endDayOfWeek == 0 || $endDayOfWeek == 6){ $end = strtotime('Last Friday 5pm', $end); } $hour = date('H', $end); if($hour < 9){ $end = strtotime('-1day 5pm', $end); } if($hour > 17){ $end = strtotime('5pm', $end); } $daysBetween = floor(($end-$start)/(60*60*24)); $day = date('w', $start); $seconds = strtotime('5pm', $start)-$start; for($i=1; $i<$daysBetween; $i++){ if($day != 0 && $day != 6){ $seconds+=(60*60*; } } $seconds += $end-strtotime('9am', $end); return $seconds; } $start = strtotime('2013-02-14 12:00:00'); // Thursday at Noon $end = strtotime('2013-02-18 10:45:00'); //Monday at 10am echo 'Start: '; echo date('Y-m-d H:i:s', $start); echo '<br>'; echo 'End: '; echo date('Y-m-d H:i:s', $end); echo '<br>'; $seconds = workTime($start, $end); echo '<br>'; echo '<br>'; echo "$seconds seconds<br>"; $minutes = $seconds/60; if($minutes > 60){ $hours = floor($minutes/60); $minutes = $minutes-($hours*60); echo "$hours hours, "; } echo "$minutes minutes"; I tested it for a few various values and it seemed to work pretty good. It DOES assume your start time is within the right hours. You should be able to add the logic to move the start time to the correct working hours if it's not in them, by looking at this.
  10. No lunch breaks? :-P Here's what I got, it returns the difference in seconds. Then you can do the math to get the hours and minutes. Edit: I forgot something hold on.
  11. Or even just md5 and substr? You'd get the exact same effect with one line of code. substr(md5(microtime()), 0, 6); Edit: I take it back, you wouldn't get capital letters. You could however take advantage of range() to not have to type out every letter, just FYI. $alphanum = array_merge(range('a', 'z'), range('A', 'Z', range(2, 9)); (Not sure why ou're skipping 1 and 0, maybe too close to l and O?)
  12. 1. You need to check for SQL errors. 2. Your INSERT syntax is wrong. 3. You're trying to use the RESULT of a query as another query at the end.
  13. The XML actually contains the string False, not the boolean value false. While PHP has loose typing I don't believe it will convert String "False" to boolean false, that would most likely cause the opposite effect of what the dev wanted.
  14. You should not be dynamically creating tables.
  15. Don't bump your posts. Go through and make sure all the quotes match. An editor with syntax highlighting will help you.
  16. You don't need AJAX for this, in fact I have no idea why you posted in this section. If you need help with specific code, post it in PHP help (or here if you actually have AJAX code.) If you just need advice on your approach, in Application Design.
  17. Yes, but we aren't here to do your homework for you. What's the point of taking a class you won't even try to learn from? If you get stuck on a specific bug or concept we can help, but you should turn to your professor or TA first anyway.
  18. So it's telling you where the problem is. Look at the mysql syntax. http://dev.mysql.com/doc/refman/5.1/en/create-table.html It looks like you need to move the index definitions inside your parens.
  19. 1. Stop using the @ error suppressor. 2. Why are you creating tables in your PHP script? 3. What is the mysql error? 4. You need to normalize your data structure. 5. You really should store images in the filesystem, not in a database.
  20. You've got to be fucking kidding me.
  21. And in the other file you have session_start() as the first line too?
  22. That code produces that error? And session_start() is the very first line?
  23. Code? Sounds like your session isn't starting.
  24. Did you read the manual? http://www.php.net/manual/en/session.examples.php http://www.php.net/manual/en/session.examples.basic.php
  25. Yep. Now go do the research I told you to, and it will make sense.
×
×
  • 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.