Jump to content
Larry Ullman's Book Forums

AlexBeau

Members
  • Posts

    5
  • Joined

  • Last visited

  • Days Won

    1

AlexBeau last won the day on July 17 2011

AlexBeau had the most liked content!

AlexBeau's Achievements

Newbie

Newbie (1/14)

1

Reputation

  1. Ok so I am going through the Review and Pursue questions at the end of chapter 9 and one of them is quite confusing to me. The question is: Can someone help me clarify what is meant by writing the CSS codes for the customize.php script. The last sentence in the question is confusing to me. Any help is appreciated. Thank you, Alex
  2. Was doing the last section of chapter 7 where you take array data from a HTML and print it back out on the screen. The script is event.php. Larry mentioned that in the real world you would use validation to make sure that a event name has been entered into the form. I gave it a shot and this is what I have come up with: <?php // Filename: event.php // Author: Alex Beauchamp // Date: 7/23/11 // This script creates an array from an html form's group of checkboxes // Error Management ini_set('display_errors', 1); error_reporting(E_ALL | E_STRICT); // Create flag variable for validation $okay = TRUE; // Validate that event name is entered, if not print error message if (empty($_POST['name'])) { print '<p class="error">Please enter a name for your event.</p>'; $okay = FALSE; } // Validate that at least 1 day is selected if (isset($_POST['days']) AND is_array($_POST['days'])) { foreach ($_POST['days'] as $day) { $selected[] = $day; $selected_days = implode(', ', $selected); } } else { // Print error message if no weekday is selected print '<p class="error">Please select at least one day for your event.</p>'; $okay = FALSE; } // If name and day okay print event details if ($okay) { print "<p>You want to add an event called <span class=\"bold\">{$_POST['name']}</span> which takes place on: <br />"; print $selected_days; } ?> Would this be the correct way to going about validating the inputs and then printing them if correct or warning if they are not correct? If not is there a better way to do it? Thank you, Alex
  3. Ok thank you. I guess I was getting caught up on the fact that you can assign a value to a variable within the if statement. Also after speaking to a few other people I learned that the variable assignment occurs before the expression is evaluated. Now that I know that I would say that because the variable $var is first assigned the value donut and then is evaluated it is TRUE. This is because it is not an empty string, and empty value or a value of 0. Am I correct in my thinking? I just want to make sure I fully understand everything before I get in to deep to not know what I am doing. Thank you for your help and your book. It has been a great introduction so far. Alex
  4. Still diligently working my way through this book and I have come to a roadblock at the end of chapter 6. The question I am having trouble with states: Without knowing anything about $var will the following conditional be TRUE or FALSE? Why? if ($var = 'donut') { I am apt to say that it will be false because we don't know if $var has been assigned the value donut yet within the program but I am not sure. If someone could answer this for me and give me an explanation so I can fully grasp this concept I would be thankful. Thank you, Alex
  5. Good evening, This book is my first foray into programming and I have a question regarding one of the tips in chapter 2. "Unlike some other languages, PHP generally doesn’t require you to declare or initialize a variable prior to use. In other words, you can refer to variables without first defining them. But it’s best not to do that; I try to write my scripts so that every variable is defined or validated before use." What do you mean by declare or initialize the variable before use? Any help with this would be greatly appreciated. Alex
×
×
  • Create New...