Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'function'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Found 7 results

  1. I must be missing something very basic but I'm stuck after several hrs of trying various solutions to this apparent function re-declaration in my config.inc.php file. Possibly after staring at the code for so long I just can't see it any more. But, I keep getting an error: Cannot redeclare my_error_handler() (previously declared in C:\xampp\htdocs\muztash\config\config.inc.php:64) in C:\xampp\htdocs\muztash\config\config.inc.php on line 91 The error seems to say that the function is being declared twice on the same page. Line 64 is the 1st line of the actual declaration: function my_error_handler($e_number,$e_message,$e_file,$e_line,$e_vars) { Line 91 is the ending } of the declaration. It matches the opening { on line 64 and there are no brace mismatches inside the declaration - which pretty closely follows the example code in the book. I have a couple of other questions but I'll focus on this one first. Thanks to whoever can help me with this.
  2. I am using the php mail function on my site for user registration, so that the user receives an email confirmation link to click on when he registers. However during testing not every email address receives the confirmation email and sometimes after sending it, I can't send email to that email address anymore, no email gets through. what could be causing it. I am using the php mail function exactly like it says in this book.
  3. Hi, I have one question about this. In the book it is written that "Doing the above would call the init() function and assign the value returned by it to the window.onload property, which is not the intent." Let's say that somewhere in JavaScript exsist the following code: var init = function() { //some code return something; } Here, a function definition is a value assigned to a variable. Now, we have: window.onload = init; and that code assigns to the onload property of the window object the value of the init variable. OK. Let's suppose that there exists the following function which does the same function init() { //some code return something; } In this case, it would be the same to use: window.onload = init; AND window.onload = init(); But in reality, this is not the case, there is no init() function, there is only init variable so it isn't the same. Am I right?
  4. Hi ,this book are really good , simple and easy to understand , don't have any problem on understanding your words so far. I have apply to two of my project . This is not really a problem , just not sure where to start off . I was trying to improve the login system , because when the user forget to click the logout button , the session doesn't logout automatically.What i trying to do is make a session expire after 15 minutes of inactivity ? Any ideas ? [sOLVED] used this solution apply to include/config.inc.php just after the session_start() Hope this can helps $live = false; // Errors are emailed here: $contact_email = 'abc@gmail.com'; define ('BASE_URI','.'); define ('BASE_URL','www.domain.com/'); define ('MYSQL', BASE_URI . '/include/mysql.inc.php'); // Start the session: session_start(); $timeout = 15; // Set timeout minutes $logout_redirect_url = "index.php"; // Set logout URL $timeout = $timeout * 60; // Converts minutes to seconds if (isset($_SESSION['start_time'])) { $elapsed_time = time() - $_SESSION['start_time']; if ($elapsed_time >= $timeout) { $_SESSION = array(); // Destroy the variables. session_destroy(); setcookie (session_name(), '', time()-86400, '/'); // Destroy the cookie. header("Location: $logout_redirect_url"); } } $_SESSION['start_time'] = time();
  5. var U = { $: function(id) { 'use strict'; if(typeof id = 'string') { return document.getElementById(id); } // end of typeof } // end of $() function } // end U object This is a rather simple question. The text says the $() function is a property of U, isn't this function technically a method and not a property? Thanks, Mark
  6. Hello, First, my very best wishes to everyone for this new year 2012. … And my first question for 2012! I'm trying to enlarge the create_form_input() function from chapter 4 so that it also takes care of labels. I've managed to do practically everything I want it to do, except that I would like the $label_text argument to have a default value, and I haven't found a solution yet. The idea is that the label text would be based on the $name variable in this way: $label_text = ucwords(str_replace('_', ' ', $name)); If there was only English to be taken into account, I could just hardcode it into the function. There would be no $label_text parameter, and I would just write: <label for="'.$name.'">'.ucwords(str_replace('_', ' ', $name)).'</label> so that if the value of $name is 'first_name', the label text is 'First Name'. But, since I want this function to handle the label text whatever language is used, I need a $label_text argument. I first thought of making ucwords(str_replace('_', ' ', $name)) the default value for the $label_text parameter, but I don't know how to achieve this since the PHP manual states that "The default value must be a constant expression, not (for example) a variable, a class member or a function call." I then thought of passing this function parameter by reference, and the beginning of the function now looks like this: function create_form_input2($name, $type, $size_rows, $maxlength_cols, $label_class, &$label_text, $input_class, $errors, $span_class='') { $value = false; if (isset($_POST[$name])) $value = $_POST[$name]; $label_text = ucwords(str_replace('_', ' ', $name)); … It works if I keep the variable for this parameter: create_form_input2('first_name', 'text', '30', '30', 'left', $label_text, 'margin_left', $erreurs); This is what I get: But if I try using a string, I get the following error message: Fatal error: Cannot pass parameter 6 by reference in …ecom1/index.php5 on line 27 Line 27 being: create_form_input2('first_name', 'text', '30', '30', 'above', 'Prénom', 'below', $erreurs); which means that I still don't understand "references" . If someone could help me find a solution, I'd be really grateful. Below: first, a few CSS classes I created so that I could either have the label and the input on the same line (as on the screen shot above), or the input below the label. Then, my attempt at rewriting the function. Then the form. ############### # CSS classes # ############### form label.left, form span.left { position: absolute; width: 8em; font-size: 1em; text-align: right; } form input.margin_left, form textarea.margin_left { margin-left: 8.7em; text-align: left; } form label.above, form input.below, form textarea.below, form span.above { display: block; } ####################### # The function itself # ####################### function create_form_input2($name, $type, $size_rows, $maxlength_cols, $label_class, &$label_text, $input_class, $errors, $span_class='') { $value = false; if (isset($_POST[$name])) $value = $_POST[$name]; // Label text based on $name. $label_text = ucwords(str_replace('_', ' ', $name)); if ($value && get_magic_quotes_gpc()) $value = stripslashes($value); // Check the input type. if (($type == 'text') || ($type == 'password')) { // Create the input. echo '<p><label class="'.$label_class.'" for="'.$name.'"> '.$label_text.'</label>'; echo '<input type="'.$type.'" name="'.$name.'" id="'.$name.'" size="'.$size_rows.'" maxlength="'.$maxlength_cols.'" '; // Add the input's value, if applicable. if ($value) echo 'value="'.htmlspecialchars($value).'"'; echo ' class="'.$input_class; // Check for an error. if (array_key_exists($name, $errors)) { echo ' error" /> <span class="error '.$span_class.'">' .$errors[$name].'</span></p>'; } else { echo '" /></p>'; } } // Check if the input type is a textarea. elseif ($type == 'textarea') { echo '<p><label class="'.$label_class.'" for="'.$name.'">' .$label_text.'</label>'; // Display the error first, so that it's more obvious. if (array_key_exists($name, $errors)) echo '<br /> <span class="error '.$span_class.'">'.$errors[$name].'</span>'; // Create the textarea. echo '<textarea name="'.$name.'" id="'.$name.'" rows="'.$size_rows.'" cols="'.$maxlength_cols.'" class="'.$input_class; // Add the 'error' class, if applicable. if (array_key_exists($name, $errors)) { echo ' error">'; } else { echo '">'; } // Add the value to the textarea. if ($value) echo $value; echo '<textarea></p>'; } // End of primary IF-ELSE. } // End of the create_form_input() function. ######## # Form # ######## <form method="post" action="" accept-charset="utf-8"> <?php $erreurs = array ('first_name' => 'Please enter your first name.', 'last_name' => 'Please enter your last name.', 'comment' => 'Please enter your comment.'); // The first three function calls work and produce the screen shot above. create_form_input2('first_name', 'text', '30', '30', 'left', $label_text, 'margin_left', $erreurs); create_form_input2('last_name', 'text', '30', '30', 'left', $label_text, 'margin_left', $erreurs); create_form_input2('comment', 'textarea', '10', '70', 'left', $label_text, 'margin_left', $erreurs, 'left'); // This is what triggers an error message: create_form_input2('first_name', 'text', '30', '30', 'above', 'Prénom', 'below', $erreurs); create_form_input2('last_name', 'text', '30', '30', 'above', 'Nom', 'below', $erreurs); create_form_input2('comment', 'textarea', '10', '70', 'above', 'Échos', 'below', $erreurs, 'above'); ?> <input type="submit" name="submit" value="Submit!" class="formbutton clear" /> </form> With thanks for your help,
  • Create New...