Jump to content
Larry Ullman's Book Forums

phpstuff

Members
  • Posts

    107
  • Joined

  • Last visited

Everything posted by phpstuff

  1. Somebody.....help!!! Here is what is printed out within the menu, between buttons CHANGE PASSWORD and SOME PAGE. Again, I just don't know what it's reffering to. I looked up "undefined index" on stack overflow and it mentioned that the error can be caused by not using ISSET for the array/variable, but I'm assuming the code is correct in the book. An error occurred in script '/Applications/MAMP/htdocs/PHP_MYSQL/includes/footer_ch18.html' on line 17:Undefined index: user_level Date/Time: 1-7-2014 23:59:25 Array( [_GET] => Array ( ) [_POST] => Array ( ) [_COOKIE] => Array ( [PHPSESSID] => 94e3d43c2a4b7370631f30dfed03bb6c ) [_FILES] => Array ( ) [_SERVER] => Array ( [HTTP_HOST] => localhost [HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:26.0) Gecko/20100101 Firefox/26.0 [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 [HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.5 [HTTP_ACCEPT_ENCODING] => gzip, deflate [HTTP_DNT] => 1 [HTTP_COOKIE] => PHPSESSID=94e3d43c2a4b7370631f30dfed03bb6c [HTTP_CONNECTION] => keep-alive [HTTP_CACHE_CONTROL] => max-age=0 [PATH] => /usr/bin:/bin:/usr/sbin:/sbin [SERVER_SIGNATURE] => [SERVER_SOFTWARE] => Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/0.9.8r DAV/2 PHP/5.4.10 [SERVER_NAME] => localhost [SERVER_ADDR] => 127.0.0.1 [SERVER_PORT] => 80 [REMOTE_ADDR] => 127.0.0.1 [DOCUMENT_ROOT] => /Applications/MAMP/htdocs [SERVER_ADMIN] => you@example.com [SCRIPT_FILENAME] => /Applications/MAMP/htdocs/PHP_MYSQL/register_ch18.php [REMOTE_PORT] => 55947 [GATEWAY_INTERFACE] => CGI/1.1 [SERVER_PROTOCOL] => HTTP/1.1 [REQUEST_METHOD] => GET [QUERY_STRING] => [REQUEST_URI] => /PHP_MYSQL/register_ch18.php [SCRIPT_NAME] => /PHP_MYSQL/register_ch18.php [PHP_SELF] => /PHP_MYSQL/register_ch18.php [REQUEST_TIME_FLOAT] => 1389157165.39 [REQUEST_TIME] => 1389157165 [argv] => Array ( ) [argc] => 0 ) [page_title] => Register [_SESSION] => Array ( [user_id] => 1 [user_tz] => America/New_York [lid] => 1 ))#0 my_error_handler(8, Undefined index: user_level, /Applications/MAMP/htdocs/PHP_MYSQL/includes/footer_ch18.html, 17, Array ([_GET] => Array (),[_POST] => Array (),[_COOKIE] => Array ([PHPSESSID] => 94e3d43c2a4b7370631f30dfed03bb6c),[_FILES] => Array (),[_SERVER] => Array ([HTTP_HOST] => localhost,[HTTP_USER_AGENT] => Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:26.0) Gecko/20100101 Firefox/26.0,[HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,[HTTP_ACCEPT_LANGUAGE] => en-US,en;q=0.5,[HTTP_ACCEPT_ENCODING] => gzip, deflate,[HTTP_DNT] => 1,[HTTP_COOKIE] => PHPSESSID=94e3d43c2a4b7370631f30dfed03bb6c,[HTTP_CONNECTION] => keep-alive,[HTTP_CACHE_CONTROL] => max-age=0,[PATH] => /usr/bin:/bin:/usr/sbin:/sbin,[SERVER_SIGNATURE] => ,[SERVER_SOFTWARE] => Apache/2.2.23 (Unix) mod_ssl/2.2.23 OpenSSL/0.9.8r DAV/2 PHP/5.4.10,[SERVER_NAME] => localhost,[SERVER_ADDR] => 127.0.0.1,[SERVER_PORT] => 80,[REMOTE_ADDR] => 127.0.0.1,[DOCUMENT_ROOT] => /Applications/MAMP/htdocs,[SERVER_ADMIN] => you@example.com,[SCRIPT_FILENAME] => /Applications/MAMP/htdocs/PHP_MYSQL/register_ch18.php,[REMOTE_PORT] => 55947,[GATEWAY_INTERFACE] => CGI/1.1,[SERVER_PROTOCOL] => HTTP/1.1,[REQUEST_METHOD] => GET,[QUERY_STRING] => ,[REQUEST_URI] => /PHP_MYSQL/register_ch18.php,[SCRIPT_NAME] => /PHP_MYSQL/register_ch18.php,[PHP_SELF] => /PHP_MYSQL/register_ch18.php,[REQUEST_TIME_FLOAT] => 1389157165.39,[REQUEST_TIME] => 1389157165,[argv] => Array (),[argc] => 0),[page_title] => Register,[_SESSION] => Array ([user_id] => 1,[user_tz] => America/New_York,[lid] => 1))) called at [/Applications/MAMP/htdocs/PHP_MYSQL/includes/footer_ch18.html:17]#1 include(/Applications/MAMP/htdocs/PHP_MYSQL/includes/footer_ch18.html) called at [/Applications/MAMP/htdocs/PHP_MYSQL/register_ch18.php:116]
  2. Having issues here... All the links show up on the page that should, but I get an error code/array printed to the page. If the "user_level" is an undefined index shouldn't it be an "index" in the table? It isn't.. Not sure the issue here. <!DOCTYPE HTML> <head> <meta http-equiv="content-type" content="text/html"; charset="utf-8" /> <title>Welcome to this Site!</title> <style type="text/css" media="screen">@import "includes/layout.css";</style> </head> <body> <div id="Header">User Registration</div> <div id="Content"> <!-- End of Header --><h1>Welcome!</h1><h1>stuff</h1> <p>Welcome to !</p> <p>related roles </p> <!-- START of Header --> </div><!-- Content --> <div id="Menu"> <a href="index.php" title="Home Page">Home</a><br /> <a href="logout.php" title="Logout">Logout</a><br /> <a href="change_password.php" title="Change Your Password">Change Password</a><br /> <div class="error">An error occurred in script '/Applications/MAMP/htdocs/PHP_MYSQL/includes/footer_ch18.html' on line 17:Undefined index: user_level<br /> Date/Time: 1-7-2014 01:38:45<br /> <pre>Array ( [_GET] => Array ( ) [_POST] => Array ( ) [_COOKIE] => Array ( [PHPSESSID] => 94e3d43c2a4b7370631f30dfed03bb6c ) [_FILES] => Array ( ) [page_title] => Welcome to this Site! [_SESSION] => Array ( [user_id] => 1 [user_tz] => America/New_York [lid] => 1 ) ) #0 my_error_handler(8, Undefined index: user_level, /Applications/MAMP/htdocs/PHP_MYSQL/includes/footer_ch18.html, 17, Array ([_GET] => Array (),[_POST] => Array (),[_COOKIE] => Array ([PHPSESSID] => 94e3d43c2a4b7370631f30dfed03bb6c),[_FILES] => Array (),[page_title] => Welcome to this Site!,[_SESSION] => Array ([user_id] => 1,[user_tz] => America/New_York,[lid] => 1))) called at [/Applications/MAMP/htdocs/PHP_MYSQL/includes/footer_ch18.html:17] #1 include(/Applications/MAMP/htdocs/PHP_MYSQL/includes/footer_ch18.html) called at [/Applications/MAMP/htdocs/PHP_MYSQL/index.php:29] </pre></div><a href="view_users.php" title="View All Users">View Users</a><br /> <a href="#">Some Admin Page</a><br /> <a href="#">Some Page</a><br /> <a href="#">Another Page</a><br /> </div><!-- Menu --> </body> </html>
  3. I figured out an issue with the above... This code: (DATE_FORMAT($last, '%e-%b-%y %1:$i %p') I have a "$" where it should be a "%" - so in the browser it was saying call to undefined variable i - which helped track down the issue quickly.
  4. Hi, The queries on the 2 pages aren't the same - the query on pg 541 is shown in example B and has run succesfully in the screen shot. The query on the top of the previous page (540, #3) is different - I typed that into the terminal and ran it and received an error: SELECT t.thread_id, t.subject, username, COUNT(post_id) - 1 AS responses, MAX(DATE_FORMAT($last, '%e-%b-%y %1:$i %p')) AS last, MIN(DATE_FORMAT($first, '%e-%b-%y %1:%i %p')) AS first FROM threads AS t INNER JOIN posts AS p USING (thread_id) INNER JOIN users AS u ON t.user_id = u.user_id WHERE t.lang_id = {$_SESSION['lid']} GROUP BY (p.thread_id) ORDER BY last DESC; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '['lid']} GROUP BY (p.thread_id) ORDER BY last DESC' at line 5 I noticed in the example B on page 541 there are many differences such as having CONVERT_TZ and setting t.lang_id = 4. Is this conflicting/wrong, or just a different example? Why does the query I entered above have this error?
  5. Looking to expand my knowledge of MySQL (after I finish this book / will also be buying the 2nd version of effortless ecommerce by Larry as well). Is the knowledge in these 3 PHP books good enough, or do you feel (open to anybody to answer) that I should invest time in a dedicated MySQL book? If so, what book would you recommend? My goal is to achieve intermediate/advanced abilites in PHP/MySQL over the next 12-18 months.
  6. Maybe a dumb question, but how do you type the characters required? For example Greek / Japanese and others use special characters.
  7. Thank you for your response. Do you feel those 2 additional validation steps would make this ready to go to a live site, or are there any other validation steps that would need to be included in order to ensure error-free operation?
  8. Ahh... Yes you are correct - the code is in the included script mysqli_oop_connect.php. That makes sense now... Here is the culprit: echo '<pre>' . print_r($mysqli, 1) . '</pre>'; It looks like it was legacy code from a previous version of the script. It was the last line of code in the script. Thanks for your help!!
  9. What other validations are necessary to make this date picker perfect? The reason I ask is that I received the below error(s) when I entered: (1) Warning: checkdate() expects parameter 3 to be long, string given in /Applications/MAMP/htdocs/PHP_MYSQL/datetime.php on line 37 One or both of the submitted dates was invalid. Set the Start and End Dates for the Event Start Date: (MM/DD/YYYY) End Date: (10/18/eeee) (2) Notice: A non well formed numeric value encountered in /Applications/MAMP/htdocs/PHP_MYSQL/datetime.php on line 37 Notice: A non well formed numeric value encountered in /Applications/MAMP/htdocs/PHP_MYSQL/datetime.php on line 52 The starting date must precede the ending date. Set the Start and End Dates for the Event Start Date: (MM/DD/YYYY) End Date: (10/18/2sd4)
  10. I understand that and agree that.... / Fetch and print all the records while ($row = $r->fetch_object()) { echo '<tr><td align="left">' . $row->name . '</td><td align="left">' . $row->dr . '</td></tr> '; } ....is responsible for actually printing the NAME and DATE REGISTERED values. What I don't understand is what's printing this: mysqli Object( [affected_rows] => 0 [client_info] => 5.5.29 [client_version] => 50529 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 0 [host_info] => Localhost via UNIX socket [info] => [insert_id] => 0 [server_info] => 5.5.29 [server_version] => 50529 [stat] => Uptime: 1043 Threads: 1 Questions: 33 Slow queries: 0 Opens: 49 Flush tables: 1 Open tables: 42 Queries per second avg: 0.031 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 4 [warning_count] => 0) Where is there any echoing of the above? I see "r" being assigned a value, and used in a while loop, but never printed. If I wanted to eliminate the above from being printed to the page, what's the solution?
  11. Isn't that excerpt of code just printing the actual data to the table which is what its supposed to do? I believe its printing the NAME and DATE REGISTERED values to a table which is correct. If I'm incorrect, and the code you pasted above is responsible for the mysql printout, then what part of my code prints the NAME and DATE REGISTERED values data to the table? To be clear, this is the part that I believe should NOT be displayed: mysqli Object( [affected_rows] => 0 [client_info] => 5.5.29 [client_version] => 50529 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 0 [host_info] => Localhost via UNIX socket [info] => [insert_id] => 0 [server_info] => 5.5.29 [server_version] => 50529 [stat] => Uptime: 1043 Threads: 1 Questions: 33 Slow queries: 0 Opens: 49 Flush tables: 1 Open tables: 42 Queries per second avg: 0.031 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 4 [warning_count] => 0)
  12. Sorry.. I didn't finish the post title and I went back to update it and you can't update it so it is cut off.... The page is showing mysql info being printed out and I'm not sure why..
  13. Below is how the page appears - it is printing out the mysql info and I'm not sure why(mysqli Object)? Your Website catchy slogan... Home Page Register View Users Change Password Login Registered Usersmysqli Object( [affected_rows] => 0 [client_info] => 5.5.29 [client_version] => 50529 [connect_errno] => 0 [connect_error] => [errno] => 0 [error] => [error_list] => Array ( ) [field_count] => 0 [host_info] => Localhost via UNIX socket [info] => [insert_id] => 0 [server_info] => 5.5.29 [server_version] => 50529 [stat] => Uptime: 1043 Threads: 1 Questions: 33 Slow queries: 0 Opens: 49 Flush tables: 1 Open tables: 42 Queries per second avg: 0.031 [sqlstate] => 00000 [protocol_version] => 10 [thread_id] => 4 [warning_count] => 0) There are currently 29 registered users. Name Date Registered Ullman, Larry September 06, 2013 Isabella, Zoe September 06, 2013 Starr, Ringo September 06, 2013 Harrison, George September 06, 2013 McCartney, Paul September 06, 2013 Lennon, John September 06, 2013 Brautigan, Richard September 06, 2013 Banks, Russell September 06, 2013 Simpson, Homer September 06, 2013 Simpson, Marge September 06, 2013 Simpson, Bart September 06, 2013 Simpson, Lisa September 06, 2013 Simpson, Maggie September 06, 2013 Simpson, Abe September 06, 2013 Chabon, Michael September 06, 2013 Greene, Graham September 06, 2013 DeLillo, Don September 06, 2013 Jones, David September 06, 2013 Dolenz, Micky September 06, 2013 Nesmith, Mike September 06, 2013 Sedaris, David September 06, 2013 Hornby, Nick September 06, 2013 Bank, Melissa September 06, 2013 Morrison, Toni September 06, 2013 Franzen, Jonathan September 06, 2013 jones-berg, mike September 18, 2013 O'Toole, Peter September 19, 2013 Dooleyberg, Amber September 26, 2013 Jones, Mike October 14, 2013 Copyright © Plain and Simple 2007 | Designed by edg3.co.uk | Sponsored by Open Designs | Valid CSS & XHTML CODE: <?php # Script 16.3 - view_users(16.3).php // This script runs a query on the username database, and retrieves all the records from the users table // This is an OOP version of script 9.6 $page_title = 'View the current users'; include ('includes/header.html'); // Page header echo '<h1>Registered Users</h1>'; require ('../mysqli_oop_connect.php'); // Connect to the database (file is placed outside of web root directory) // Make the query (dr = date registered) $q = "SELECT CONCAT(last_name, ', ', first_name) AS name, DATE_FORMAT(registration_date, '%M %d, %Y') AS dr FROM users ORDER BY registration_date ASC"; $r = $mysqli->query($q); // Count the number of returned rows $num = $r->num_rows; if ($num > 0) { // If it ran OK meaning the query returned at least 1 record, display the record(s) // Print how many users there are: echo "<p>There are currently $num registered users.</p>\n<br />"; // Table header echo '<table align="center" cellspacing="3" cellpadding="3" width="75%"> <tr><td align="left"><b>Name</b></td><td align="left"><b>Date Registered</b></td></tr> '; // Fetch and print all the records while ($row = $r->fetch_object()) { echo '<tr><td align="left">' . $row->name . '</td><td align="left">' . $row->dr . '</td></tr> '; } echo '</table>'; // Close the table $r->free(); // Free up the memory resources (an optional step that is considered good form) unset($r); } else { // If it did not run OK echo '<p class="error">There are currently no registered users.</p>'; } // End of if ($r) IF // Close the database connection $mysqli->close(); unset($mysqli); include ('includes/footer.html'); ?>
  14. This book uses JS - what are the use cases and pros/cons of each? (in addition to PHP server side validation of course) I understand users can disable JavaScript... Can HTML5 validation be thwarted like JS? If not, is it then better? Isn't HTML5 approach less taxing from a resources perspective? Thanks!
  15. Obviously regexs are one of the more complicated things to master. Since I have a limited amount of study time, I'm curious how important it is to understand regexs, and to what degree? I have a basic understanding... In other words, am I better off crossing that bridge when I get to it (and then searching online for regexs that others have developed)? Are regexs found in many PHP web applications? What are the most common instances that you would see websites needing regexs? Thanks!
  16. I believe there are books like that, however, we should probably learn each area first really well and then combine them.
  17. The book mentions the consistency that may be associated with using the Filter extension, as opposed to using strip_tags(), etc. The book didn't discuss pros/cons of using either, beyond the consistency factor with the Filter extension. I like the consistency factor - this is a bonus for me to keep things simple and clean - beyond that are there any downsides? Is it slower, does it tax the server more, does using one over the other make it easier to code other sections of your application, etc?? Thanks!
  18. Very cool - thanks guys. I'll spend some time investigating all of this further - I'm sure using the proper tool to get the job done makes you that more efficient and I'm willing to put in the time to learn.
  19. From pg 395 of the book: "Unlike when using the cookie version of the logout.php script, you cannot refer to the user by their first name anymore, as all data has been deleted." What if we don't like this method? If we would prefer to provide the user with a more personalized logout message (rather than "You are now logged out!), couldn't we take the value of the user's name ( $_SESSION['first_name'] ) and stuff it into a variable prior to deleting the session, and then use that variable within the logout message? I think this works below - do you see any issue with what I did here?: <?php # Script 12.11 - logout.php #2 // This page lets the user log out // This version uses sessions session_start(); // Access the existing session. // If no Session Variable is present, redirect the user if (!isset($_SESSION['user_id'])) { // Need the functions require ('includes/login_functions.inc.php'); redirect_user(); } else { // Cancel the session // *** ADDITIONAL CODE ADDED BY ME: // *** Prior to deleting the session and access to first_name, // *** add the value to another new variable to preserve its use when logging out: $users_first_name = $_SESSION['first_name']; $_SESSION = array(); // Clear the variables session_destroy(); // Destroy the session itself setcookie ('PHPSESSID', '', time()-3600, '/', '', 0, 0); // Destroy the session's cookie } // At this point we now longer have access to session info / cookie info, but we do have access to the user's first name via $users_first_name // Set the page title and include the HTML Header $page_title = 'Logged Out!'; include ('includes/header.html'); // Print a customized message echo "<h1>Logged Out!</h1> <p>You are now logged out, $users_first_name!</p>"; include ('includes/footer.html'); ?>
×
×
  • Create New...