Jump to content

Jessica

Staff Alumni
  • Posts

    8,968
  • Joined

  • Last visited

  • Days Won

    41

Everything posted by Jessica

  1. http://www.php.net/manual/en/language.types.string.php
  2. '$password' is a literal string of $password. Not the value contained within $password.
  3. Please don't do that. You should never have code copied on multiple pages. You have a few options for solving this problem. A. Have your form on one page, and the processing for the form on a second page. When you submit the form, go to the processing page to handle it. Then use a header redirect to send the user back to the form page or a third confirmation page to display any errors or success messages. They can then refresh the page all they want, it won't hurt anything. B. Keep everything on one page, but instead of simply displaying after the processing, use the same header redirect back to the same page. Either way, you need to store your messages in the SESSION then send the user to some kind of confirmation page when you're done, using a redirect, so they cannot use refresh to resubmit the form.
  4. You shouldn't be striping slashes from data in your database because by the time it's in the database it shouldn't have any extra slashes. You also spelled the function name wrong. You need to use a string with quotes in your array key. You need to check for SQL errors when doing any queries. To debug this particular error, try a print_r on row immediately after the fetch.
  5. Well based on your code you aren't doing any queries.
  6. Why go to that trouble when you can use an auto incrementing field?
  7. Not the entire website, but the products pages. If the only difference between the two folders is they have different subcategories and attributes which you already store in a folder, what could possibly be different in the PHP files for each?
  8. Well, it depends on how you're using the variables. That's not an error with WAMP, that's strict error reporting. It's a good thing. It's alerting you to flaws in your code.
  9. That is what mod_rewrite does. You really shouldn't have folders for each room. You could do all of that with ONE php file, and a database. The subcategories, attributes, etc should all be stored in the DB.
  10. If installing WAMP is too much trouble, installing them separately will be way too much trouble. I've never gotten a single error installing WAMP on a PC. What errors do you get? (Moving this to installation and setup forum.)
  11. So, that's a big improvement. Good job (Please use the code tags so we can read your code easier). I would not use the actual question as the key. You also cannot have multiple values at the 0 key, so you shouldn't be able to see all your answers... Try something like this <?php $quiz = array( array( 'question'=>'Question 1', 'choices'=>array( 'Choice 1-1', // Correct 'Choice 1-2', 'Choice 1-3', 'Choice 1-4' ), 'correct_answer'=>1 //Could do either the 0-based array key or the 1-based key, I chose 1 to be visually friendly ), array( 'question'=>'Question 2', 'choices'=>array( 'Choice 2-1', 'Choice 2-2', 'Choice 2-3', // Correct 'Choice 2-4' ), 'correct_answer'=>3 ), ); Then make sure each radio set has the name of "question[$id]" where $id is the array key of the current question and the values are the array keys of the answers. You'll have X distinct sets where X is your number of questions. That will give you an array in $_POST that contains all the question IDs and the related answer ID.
  12. What is line 268 (and the few around it) of file /home/acc/public_html/itsmywiki.com/skins/Vector.php??
  13. You need to use some logic in PHP. Where is the data coming from? Basically you need to order them by the parent (In your case, A and B ) and then keep track of which one you're printing when you output. I wrote an article about this on my site. It's using MySQL but the logic is the same no matter where your data comes from. http://thewebmason.c...t-child-lists/ Just saw you posted this in MySQL so I'm going to assume it's a MySQL Database
  14. Since PHP is server side, and you know what you need to do is client side, what could you possibly be asking?? I think my favorite part is that you posted this in the MySQL help forum.
  15. You know what you should probably move the HOUR checks to before the WEEKEND checks. I think?
  16. <?php function workTime($start, $end){ /* Adjust End Time */ //If the end time is not a weekday, move it to the end of last week. $endDayOfWeek = date('w', $end); if($endDayOfWeek == 0 || $endDayOfWeek == 6){ $end = strtotime('Last Friday 5pm', $end); } //If the ending hour is outside the work range of 9am-5pm, move it to the acceptable time $hour = date('H', $end); if($hour < 9){ //the previous dat at 5pm $end = strtotime('-1day 5pm', $end); } if($hour > 17){ //Today at 5pm $end = strtotime('5pm', $end); } /* Adjust Start Time */ //If the start time is not a weekday, move it to the start of next week. $startDayOfWeek = date('w', $start); if($startDayOfWeek == 0 || $startDayOfWeek == 6){ $start = strtotime('Next Monday 9am', $start); } //If the starting hour is outside the work range of 9am-5pm, move it to the acceptable time $hour = date('H', $start); if($hour < 9){ //same day at 9am $start = strtotime('9am', $start); } if($hour > 17){ //next day at 9am $start = strtotime('+1day 9am', $start); } /* Calculate Difference */ if(date('Y-m-d', $start) == date('Y-m-d', $end)){ //The dates are the same day and have been adjusted to be within 9am-5pm, just subtract the times. $seconds = $end-$start; }else{ //How many days (rounding down) are between the start time and the new edited end time? $daysBetween = floor(($end-$start)/(60*60*24)); $day = $startDayOfWeek; //We need to track what day of the week we are adding hours for, so we can skip weekends. //The seconds for the first day from work started until the end of the day at 5pm $seconds = strtotime('5pm', $start)-$start; //The rest of the days for($i=1; $i<$daysBetween; $i++){ $day++; //Add a day if($day > 6){ //If it's greater than 6 roll back to 0. $day = 0; } //If it's not a weekend if($day > 0 && $day < 6){ $seconds+=(60*60*; //Add 8 hours worth of seconds. } } //Add the last day's worth of work. $seconds += $end-strtotime('9am', $end); } return $seconds; }
  17. There's some bugs in it, but I think it's a starting point anyway.
  18. To be fair, I didn't comment it. Here's what my function looks like right now, and it worked for the several examples you've provided. 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); if($daysBetween > 0){ $seconds = strtotime('5pm', $start)-$start; for($i=1; $i<$daysBetween; $i++){ $day++; if($day > 6){ $day = 0; } if($day != 0 && $day != 6){ $seconds+=(60*60*; } } $seconds += $end-strtotime('9am', $end); }else{ $seconds = $end-$start; } return $seconds; } Testing some times $dates = array( array('start'=>'2013-02-15 16:50:00', 'end'=>'2013-02-18 09:00:00'), //10 mins array('start'=>'2013-02-19 09:00:00', 'end'=>'2013-02-19 10:30:00'), //1.5 hr /*array('start'=>, 'end'=>), // Put more examples in here array('start'=>, 'end'=>), array('start'=>, 'end'=>),*/ ); foreach($dates AS $date_set){ $start = strtotime($date_set['start']); $end = strtotime($date_set['end']); echo '<p>Start: '.date('Y-m-d H:i:s', $start).'<br>'; echo 'End: '.date('Y-m-d H:i:s', $end).'</p>'; $seconds = workTime($start, $end); echo "<p>$seconds seconds</p>"; echo '<p>'; $minutes = $seconds/60; if($minutes > 60){ $hours = floor($minutes/60); $minutes = $minutes-($hours*60); echo "$hours hours, "; } echo "$minutes minutes</p>"; } Output: I'll go through and add some comments to help explain it.
  19. That's javascript.
  20. Your function doesn't make any sense, why bother doing a foreach if you're just going to return the first value? Use array_shift() for that. Your assignment says to use ONE array. You're using several. Your answers aren't related to your questions in any way. Go look at Example #6 in the manual. http://www.php.net/manual/en/language.types.array.php Once you have your array structured correctly it would be elementary to foreach() through it and list the Q/A. Edit: By the way, the song is called "Cups", and the character's name is Bumper with a p. Edit 2: Arrays start at 0 by default, you don't need to start the first one with a 0 key.
  21. I have NEVER seen that on a website. What you're describing sounds like either a javascript effect or they're putting info in the title attribute of the img tag.
  22. You shouldn't even have a separate page for each Room unless there are actually significant differences in what you display for each room (ie, does each room display a list of products? That's one PHP file.) To answer the question you would use URL rewriting (mod_rewrite) to get the parameters onto the query string and use $_GET. A basic URL would look like room.php?room=bedroom And you'd have your URL be room/bedroom And use mod_rewrite to get it to show room.php?room=bedroom to PHP. Then your file would do $room = $_GET['room']; and go from there.
  23. I thought about that Psycho but I think that's more work because you're subtracting weekends and the other 16 hours per day. Mine ignores weekends and adds 8. Not sure if it makes sense. OP said he is not counting weekends. "(It excluded Saturday and Sunday!)"
  24. It appears the wordpress directory is the webroot.
×
×
  • 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.