Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

hallaplay835's Achievements


Newbie (1/14)



  1. Oh, I see. Not sure if we wouldn't want to display an error message in case it is an E_RECOVERABLE_ERROR, PHP manual should give examples of each type of error and not just an abstract description. But now your version makes sense; should have looked into this further before posting. Also ignore what I said in my earlier post, E_STRICT errors wouldn't cause the error message to be displayed, don't know where my logic went wrong. Nevertheless, this should have been mentioned in the book; maybe you'll want to include it in your upcoming edition. By the way, Larry, I have not gone into this one too much but I sense this is yet another of your excellent books among the others I have read from you. Keep up the great work!
  2. Hey there. On pages 52 (where the script is displayed) and 56 (where the steps are outlined), in the error handling function, a conditional checks to see whether the error type is either E_NOTICE or E_STRICT. If they are, Larry suggests "no message error should be printed, as the error is likely not interfering with the operation of the page". Since PHP 5 the E_STRICT constant has had a value of 2048, so the conditional should check whether $e_number equals 2048 for this type of error. Shouldn't then the conditional printed in the book: if (($e_number != E_NOTICE) && ($e_number < 2048)) { be rewritten to: if (($e_number != E_NOTICE) && ($e_number != 2048)) { Why would we want to check for a smaller than 2048 error code value? In case an E_STRICT error occurred the page would still display the generic error message.
  3. HartleySan, you can always use CSS attribute selectors to target specific elements with certain attributes; this way there is no need to add unnecessary markup that will make it less semantic. So in your CSS file you would write: ​input[type="radio"] { /* CSS declarations.*/ } CSS attribute (and value) selectors are a neat way of achieving this. They have been around for lots of time now (CSS2), it is just that people do not use them much. They are supported by every major browser, including IE > 6. CSS3 advanced pseudo-selectors can offer better ways of targetting specific elements without adding unnecessary classes, IDs or extra markup, but be careful with those if you intend to support older browsers. Similar things can be achieved using JavaScript. Lastly, experiment and check out how your form could be styled. Also, in your earlier post, make sure to close correctly the <input> element in order to write correct XHTML, if you are so keen on writing perfect code that will validate. Tags like input or br that do not have a closing tag should be closed correctly like so: <input type="radio" name="gender" id="male" /> <br />
  4. Larry, in your 4th edition of PHP and MySQL for Dynamic Web Sites, you use several times the FILTER_VALIDATE_INT filter with the filter_var() function in order to validate form input as positive integers (that is, natural numbers excluding zero, depending on whether you count zero as a natural number). To accomplish this you write in your book: filter_var($var, FILTER_VALIDATE_INT, array('min_range' => 1)) However, according to the PHP function reference, the third argument passed to the filter_var() function needs to be an associative array named $options. Inside this array you should then create another array and define the options there. So you would write: filter_var($var, FILTER_VALIDATE_INT, array('options' => array('min_range' => 1))) You can also establish the 'max_range' option for this type of filter. A complete list of available filters to be used with filter_var() can be found here. Options to be established for validate filters can be found here. I have tested this in PHP 5.3.8 (can someone test using other PHP versions?) and when using the approach specified in the book, PHP ignores the third argument (it does not complain strangely enough) and will accept negative numbers (not zero however).
  5. Hi, I do not know where is the error. According to the PHP manual, ceil() will "return the next highest integer by rounding up the provided value if necessary". According to the code, if $display = 5, and $total_records = 15, then $pages should be equal to 3, as there will be no remainder from the division and the ceil() function should not have an effect (resulting an integer). I do not see what is the use of testing for the remainder of the division using the ternary operator as there should be no effect whatsoever. I have even tried out the code myself and it seems to be working fine, I have 15 records in my database, $display is set to 5 and the page displays three links to paginate them. Is there something I am not taking into account? Help much appreciated.
  • Create New...