Jump to content
Larry Ullman's Book Forums


  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Matt

  1. Chapter 17 Specifically what you are looking for is: pgs. 558-560 ("browse_prints.php") pgs. 561-568 ("view_print.php" and "show_image.php")
  2. I am working on a site which uses the site modularization from Chapter 2 (thanks Stuart for the help with that). The problem I am having is that I need to run a second query within the "result set usage" of a prior query. What I mean is that I will run the first query, and then depending upon a boolean value from a field in the result set, I will run a second query. The problem is that once the second query is finished, I need to continue using the result set from the first query to construct a navigation menu in the footer.php file. Here is pseudocode to illustrate: 1) The first quer
  3. Larry, I didn't know that, but it makes sense! Thanks for the clarification! Matt
  4. I had no idea this was the case, but it all makes perfect sense now that I think about it! You definitely know your stuff Stuart! Thank you! Matt
  5. So I should be using the BASE_URI then? Thanks a lot for that Larry! Very much appreciated! Matt
  6. Stuart, Thank you very much for your help! The code works perfectly! However, I have just discovered a strange problem with using the $_GET method. I am using the following code at the top of the script to check which type of request method was used (i.e. GET, POST, or none) and it works fine: if ($_SERVER['REQUEST_METHOD'] == 'POST') { include ('../../includes/gallery_login.inc.php'); $include = 'gallery_content.inc.php'; } elseif (($_SERVER['REQUEST_METHOD'] == 'GET') && isset($_GET['p'])) { if (array_key_exists($_GET['p'], $pages)) { $include = $_GET['p'] . '.inc.ph
  7. Well, here we go with the absolute path errors again! In my file I'm trying to include the following file: include ('http://' . BASE_URL . 'includes/gallery_login.inc.php'); Here is my BASE_URL definition in config file: define ('BASE_URL', 'www.tuesdaygirl.org/'); Which a third grader could tell you should result in this: http://www.tuesdaygirl.org/includes/gallery_login.inc.php However, once again, error, after error, after error!!! An error occurred in script '/var/www/html/includes/show_school.inc.php' on line 37: include() [function.include]: URL file-access is d
  8. HartleySan and Stuart, Thank you both for your input on this! Stuart, your solution is brilliant! HartleySan, I know you don't have this particular book, but by matching the page the user is trying to access with a value stored in an array (or in Larry's case, by using a switch statement), there is absolutely no way that anyone can access content they're not supposed to! Stuart and Larry are pretty much doing the same thing, except that Stuart further restricts users to certain pages based on whether they are logged in or not, which is essentially what I was trying to accomplish.
  9. Hi Larry, Sorry I've been away from from the forum for a while. Was taking a break from php and busy at work. What I am trying to do is merge the example on Website Modularization in Chapter 2 with your code from Site 1 from the E-commerce book. The modularization code is straight forward, however, what I want to do is limit the pages which can be accessed depending on whether a user is logged in or not. I'm still in the brainstorming phase, but I imagine that since the login form is in the footer, then that can be left as is and won't affect the code which handles the "modulariz
  10. Interesting point, however, "Primary Key" is the standard naming convention used in all RDBMSs for the column which uniquely identifies each record in the table. Also, thanks for the link!
  11. HartleySan, Thank you so much for this! Since I will only be checking one field the code will be even easier! I could just return the whole query result from Ajax. Are query results delimited by anything besides whitespace? Should the following line read: var aSeparatedData = oAjax.responseText.split(' '); // oAjax is your Ajax object. Matt
  12. The problem is that the onChange event is being fired when the user clicks outside of the text input field, therefore, they are not getting Ajax updates as they are typing the characters, but rather after they have finished typing and clicked somewhere else. This is far too late in my opinion! What about doing the query, which selects all the usernames, when the page first loads. The query results are then put into an array. Then, I could use the onKeyUp event to constantly check the arrays and show the messages. Since it is all being done on locally on the user's machine, then there i
  13. Thanks Paul! Since I'm pretty new to javascript, I really appreciate the code example! I'll try it out! Matt
  14. Well, it does look awesome, and it works like I want, however, I see what you mean! What are the alternatives then?
  15. I made the changes and it works perfectly! The only problem is that, if at any time you hit the ENTER key while you are focused on the "username" field, the Ajax message will disappear. The only way to make it return is to click back in the "username" field and start changing the value again. It's a minor problem, but it obviously isn't going to be acceptable on a live site! Is there any way I can re-trigger the Ajax request whenever the user hits the ENTER key, or is there another solution to this problem? I have a lot of programming experience, but I'm pretty new to javascript (we
  16. Jonathon and Josee, Thank you both for the helpful advice! I will try your ideas and let you know how it works out! Thanks again, Matt
  17. Hello everyone, I have tried the first Ajax example in Chapter 13 and it is working fine! The problem is that I want to use this code for an actual site I'm developing and there are two problems. 1) The screen updates are too slow. I originally thought that the onChange() event was fired after each keystroke, however, what I figured out is that the event is fired only when a user focuses out of the "username" input field. This can be confusing to the user! Let's say he/she types a username and then focuses on the next field. At that point a "Username is unavailable!" message is d
  18. I've got it! I think I'm going to have about 8 constants for the various gallery includes (header, footer, content,etc...), but I don't think this will be a problem. Thanks Larry!
  19. Sorry to attack you earlier HartleySan, but I am just really careful about questioning people's background knowledge, especially since the MikeMikeMike incident (and Mike made it clear in his posts that he was having a hard time with some of the more fundamental concepts). I was new to this forum a couple months back and got a bit of the same "newb" treatment, and I have an IT degree and have read several of Larry's books! Anyway, page 265 of the E-Commerce book has an excellent example of a multiple INSERT stored proceedure - HartleySan, I do have Larry's book in front of me right now
  20. HartleySan, I apologize for interjecting here, but why are you questioning his logic? Nick obviously knows what he's doing! This situation happens all the time and has nothing to do with proper normalization! If anything, normalization (which I am in no way saying shouldn't be done) can exacerbate the problem. I dealt with a similar situation recently with my gallery creation pages where I was going to insert data into the "galleries" table and "profiles" table after the user had gone through a process of filling out a form for both!
  21. I think I understand what you want to do! Are you saying that you want to perform an insert into 2 tables at the same time? There are a couple of solutions to uploading to two tables at the same time. 1) Perform 2 separate INSERT queries using standard sql. 2) Use a stored procedure. The added benefit of using stored procedures is that if any part of the query fails, then the whole thing can be rolled back. Is this what you want to do? Matt
  22. Jonathon and Larry, Thanks a lot for your help! Ok, I'll convert everything to absolute paths! Also, Larry, when you say create a constant, you mean one for the "includes" folder right? My "includes" folder is getting pretty filled up with files. I'm starting to think I should also create a separate one for the gallery files (i.e. "gallery_includes"). This way the site will be more compartmentalized and better organized. Yeah Jonathon, I heard that you can set up include paths in .htaccess files. Is this what you were referring to?
  23. Thanks Larry! Sorry I didn't respond sooner. Just to clarify, for each include I would do the following: include (BASE_URI . 'html/includes/gallery_content.inc.php'); There is also the paradox of how to include the config file. Should I use: include ('home/tueslcom/html/includes/config.inc.php'); or include ('../../includes/config.inc.php'); I know that most of this is just semantical, but I think it is still important and others can learn from it. Thanks again Larry, Matt
  24. Larry, I hope this doesn't sound too moronic on my part (since databases are more my strength), but I notice that you use "UNIQUE" to define indexes in "PHP 6 and MySQL 5: Visual QuickPro Guide" and you use "UNIQUE KEY" in the "E-Commerce" book. What is the main difference between the two? Are UNIQUE KEY indexes only applied to secondary keys, or are they just a way of defining another key in a table (which could just as easily be done with UNIQUE or KEY)? Information online about the differences between these is really sparse, so if you could elaborate on this I would be extremely t
  25. Thank you so much Larry! I agree about using absolute paths. I just did it this way when I was developing because it was the only way that worked without too many headaches! I had originally tried to use absolute paths in the include statements, but kept getting errors. Doing the following: include(BASE_URL . 'includes/something.php'); ...always caused errors! I will try it again and see if I was overlooking something. Should I use 'BASE_URI' instead? Which is better? This can get quite confusing! Or, should I define a constant like this: define('INCLUDES','www.examp
  • Create New...