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. 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.
  3. probably need to do an if check before the for($i=1; $i<$daysBetween; $i++){ starts.
  4. 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.
  5. 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.
  6. for($i=1; $i<$daysBetween; $i++){ $day++; if($day > 6){ $day = 0; } if($day != 0 && $day != 6){ $seconds+=(60*60*; } } Fix that section.
  7. 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.
  8. 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.
  9. 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?)
  10. 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.
  11. 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.
  12. You should not be dynamically creating tables.
  13. Don't bump your posts. Go through and make sure all the quotes match. An editor with syntax highlighting will help you.
  14. 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.
  15. 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.
  16. 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.
  17. 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.
  18. And in the other file you have session_start() as the first line too?
  19. That code produces that error? And session_start() is the very first line?
  20. Code? Sounds like your session isn't starting.
  21. Did you read the manual? http://www.php.net/manual/en/session.examples.php http://www.php.net/manual/en/session.examples.basic.php
  22. 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.