Jump to content
Larry Ullman's Book Forums

Matt

Members
  • Content Count

    173
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by Matt

  1. I think what he means, and I may be wrong, is he want's to store all the different print items in one table, the custom designs in another table, and then link them in an 'orders' table with foregin keys. Is this what you were saying Ben?
  2. Larry, I`ve implemented the changes and everything appears to work fine! What I've done is written the directory name to a variable in the index.php file, so that this can be used by the database query to grab all the data for that specific gallery. I also use it when an artist visits another gallery which isn't his/her own. In the sidebar menu, there is a conditional which compares this variable with the 'directory_name' pulled from the database when he/she logs in. If they are different, then the sidebar will only display a link to his/her gallery. If they are the same, then the
  3. Larry, Thank you so much for your good suggestions! When I fist saw this, I thought "Damnit! Larry's throwing a wrench into our great design!" (Larry, you know how I am). However, after rereading the post, I realized that Larry is 100% right! Why are we using a function to create the page at runtime, when an included script can do the same thing without all the database connection headaches! Then I talked to HartleySan and he brought up a good point! The index page that creates a gallery is very simple. It contains just an include for the gallery_functions.inc.php file and a
  4. Thanks for the detailed explanation Larry! That was exactly what I wanted to hear. With all the talk of frameworks on this forum, and elsewhere, I just wanted to get a good idea of when it's appropriate to use them or not. I guess I'm bringing in a little backgroud from Flash into this. There are literally hundreds of Actionscript 3 APIs available on the web. I have often used them for one thing or another because I don't want to reinvent the proverbial wheel. However, I am very particular about things, and what I find myself doing 9 times out of 10 is customizing the API to suit my need
  5. Great answers Antonio! Absolutely! I talked with HartleySan about this on the phone last night, and I kind of agreed with him that it was filtering data, but only to the extent that it was grabbing columns from the joined tables which matched the WHERE clause. You put it much better! Also, HartleySan was asking me questions about queries like "How do you choose which table to start with?" I told him that I look at the first table in the select statement as the root, or home, table. This table, in my view, becomes the "left" table, and all joins are carried out to the "right" o
  6. Larry, Sorry to sound abrupt, but I really have to ask; Why in the hell would I want to use someone else's glorified api (which is all a framework is in my opinion) when I can do things myself using your books? I mean, what is the point of learning anything about php if I can just bloat my server disk space with someone else's code (half of which I`ll probably never need) and just call functions? Can you give any specific examples of when a framework might be better to use? Can they replace the brilliant code you have given us in the E-Commerce book? When I hear all this ranting and
  7. Apparently empty() does the same thing as the above! I found this code in the comments on php.net: <?php if (isset($var) && !empty($var)) { echo $var; } else { echo "missing variable '$var'"; } ?> The only problem is that it considers 0, and "0" to be empty values and returns TRUE!
  8. Jon, I agree. However, if you get anything out of Larry's books, then the thing that is glaringly obvious is that nothing can be overlooked when dealing with data! Always assume the worst and then work backwards! That's what separates half ass web programming from good! Thank you! I will test this.
  9. Ah, I see what you are saying! I thought you were insisting that I create a boolean field in the 'users' table to indicate whether a gallery had been created. My apologies for that! I will look into your suggestions!
  10. Thanks HartleySan, but that is completely an "apples" and "oranges" comparison! In the case of the user registration system, Larry is only doing a SELECT query on one table, and he is checking for the presence of a hashed value to see if someone had confirmed their registration through an email or not! What I'm doing is very different! I should have explained it clearer above (it is a little complicated), so I apologize for that. I am doing a LEFT OUTER JOIN on two tables. The query will always output one, and only one row (given that there are no errors in the data integrity) from t
  11. I now have everything stored in session variables and they work fine! However, I have another question: How do you check to see if a field returned in a query is NULL or empty? I did a search on google and found some answers in other forums, but they were all over the place. People were arguing with each other over the best way to do this, and I thought that this should be pretty straight forward. The reason I ask is because I need to do the following check when a user logs in: In the login.inc.php script, I run a LEFT JOIN query on the `users` table and the `profiles` table in
  12. Larry, I would have to say yes! HartleySan and I can probably figure it out, but since a bad decision could jeopardize database security, I would like to hear what you think would be the best solution. Also, why is it that declaring the $dbc variable as global at the top of the mysqli_connect script leads to a security risk? First of all, nobody even knows the name of the variable. Second, how can they access this script if it is outside the web root? Thanks a lot! Matt
  13. MikeMikeMike, I can somewhat agree with you on that. I have also ran into situations where I felt the same way and it can be frustrating. However, given the nature of your questions, I feel like you are having trouble with some of the fundamental concepts of database design. I don't mean to steer you away from buying Larry's books (although you mentioned that you already had a few of them), but maybe you might consider supplementing them by enrolling in a web programming/database class at a local community college. The knowledge/experience you would gain would be invaluable!
  14. HartlySan, yes! The user will be directed back to their gallery index page. I almost forgot about that. With the code above, if they logout while visiting another gallery, they will be redirected to that other gallery's index page after logout. I'm starting to think I need to store each user's gallery url in a session variable. Making a call to the database during logout is simply not acceptable!
  15. Thanks for the reply Jonathon! That's what I'm starting to think would be the best way. I'm thinking I should have the logout link to another page. <a href="logout.php?returnpage=". $SERVER['PHP_SELF'].">logout</a> Then have the following in the logout.php script. <?php //Start session session_start(); $page = isset($_GET['returnpage']); // Destroy the session: $_SESSION = array(); // Destroy the variables. session_destroy(); // Destroy the session itself. setcookie (session_name(), '', time()-300); // Destroy the cookie. header("location: $page"); ?>
  16. I am working on a site based on Example 1 from the book. As it is written, when a user logs into the site a "logout" link is displayed on the sidebar. When the link is clicked, it calls another page, logout.php, which logs the person out. What I want to do is keep everything modular and never have the user leave the index.php page. Instead, when a user logs out I would like them to be redirected back to the same index.php page and have the login form display again. I tried playing with this today, but ran into all sorts of errors! The way I think this should be handled is
  17. Jon, Are you insane? Larry was about to answer!
  18. Larry, Thank you so much for your help! The answers you gave were just what I wanted to hear - well not really, but you know what I mean The problem is a bit out of the ordinary, so one of the solutions I posted (or a better one which I hadn' thought of) is absolutely necessary for the database connection to work right. I know you are busy, but you might want to look back in the thread a bit just to see what's going on here. Here`s a recap: The mysql_connect script is being used in 2 different scenarios: 1 - It is being included within a function - in the case of the indiv
  19. MikeMikeMike, Sorry if my answer was not clear enough for you. I was just trying to help! As far as why you were only getting 10 results for the query which included the "ON" clause, I was 100% right! I originally said "The answer to this question is fairly easy! You are essentially selecting all records from the specific_coffees table WHERE the general_coffee_id = 3. If you look at the specific_coffees table, there are exactly 10 records, and all of them have a general_coffee_id of 3, so you should therefore have 10 records in your query result!" The key parts from the origin
  20. Sorry MikeMikeMike! I didn't know how far along you were with using SQL. The answer to this question is fairly easy! You are essentially selecting all records from the specific_coffees table WHERE the general_coffee_id = 3. If you look at the specific_coffees table, there are exactly 10 records, and all of them have a general_coffee_id of 3, so you should therefore have 10 records in your query result! As for why there are 30 records when you take out the ON clause, I would need to look at the query more and think about it. Whatever the reason, there is some sort of a Cartesia
  21. Well now that I have that working, there are a few different ways to implement it. Since the mysqli_connect file is being used both within a function (in the case of the galleries) and outside (in the case of the top level index page), both situations need to be handled by the database connection script. I have found 3 possibilities that all seem to work, however, I wanted to know which is the best, most secure way to implement it! A - Declare the $dbc variable as global at the top of the mysqli_connect file: <?php // This file contains the database access information. // T
  22. To understand why this is happening, then we first have to understand what the "ON" clause is doing within an INNER JOIN. This is taken from the mysql website: The "ON" clause is used in an inner join query to select data from 2 tables where a match is made between data in one column from one table and one column in the other. In your example, "ON s.id = sc.size_id" is looking for matches between data in the "s.id" column and "sc.size.id". Wherever a match is made, then those records are being selected, if and only if, they match the data defined in the "WHERE" clause. I hope t
  23. Noob, You mention Flash/Flex, but Actionscript (which is what I think you are referring to) is based on C syntax and certainly has a lot of the same "gotchas" found in those languages - you can read the wikipedia page link you posted to find some of them. However, Larry pretty much summed it up! What you need to do is study your ass off like I did and spend a lot of time developing with the Flex/Flash IDEs. I have been using Flash on and off for years and have read Actionscript 3.0 books to the point of nausea. I think I'm pretty knowledgeable with the technology, yet I still only c
  24. "Noob", I came from the exact background as you (learned AS 3 using Flash CS and then moved on to Flex), so I have asked the same questions before! I agree with Larry that using the "Cookbook" series is great! I also find these resources to be very helpful as well: Tour de Flex - This site, which is part of Adobe, is a must see resource for all Flex related topics! If you download the AIR app. there are literally hundreds of examples (with code) showing you how to do just about anything you can imagine! gotoandlearn - This is a great site by Adobe engineer Lee Brimlow, wh
  25. I'll try to explain. Do you want the short version or the long version? I'll try the short version. What I'm doing is allowing a user who registers with my site to create his/her own art gallery. Once they register, they then fill out a form with various information ("gallery name", "directory name", "gallery description", etc...). As soon as this form is submitted, a folder is instantly created with the directory name they provided in the form. An index file is created on the fly and dropped into this folder as well. What is essentially happening is they are creating a site within
×
×
  • Create New...