Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

  • Days Won


Terry last won the day on June 10 2011

Terry had the most liked content!

Terry's Achievements


Newbie (1/14)



  1. Hi, I am trying to come up with a way to validate multiple forms with ONE validation file or function. Problem is each form would have different fields, some maybe same, and could be empty. I was thinking of doing a check of isset and not empty before allowing validation of each field but what happens if a particular field is empty but is required? I am using an altered form_functions.inc.php file, it is essentially same as in book but added a few field types that weren't in there, checkbox, radio fields etc... I would like to simplify the validations into a function or altered validation.php file that gets included on each form page but I am having difficulty thinking through the logic on this. I just want fields that exist on the form to be validated and those that don't exist get by passed and NO error gets returned if the validation code thinks it should exist and is just empty when in fact that field does not exist on the form at all. I am trying to prevent creating seperate validation pages for each form, just do it all in one place that gets called and handles all validation no matter what type of form or fields exist.. eg: registration, login, questionaire, poll, profile pages or what have you. Maybe there is an obvious way here I am just not seeing it right now. Thanks for any help.
  2. Hi, Yeah, I checked out that link and apparently there is an issue with 5.3+ with that command. I didn't totally understand what it meant about the need to pass variables, sort of extra work seems to me and duplicates setting up static variables seems to me anyway. Though I am not sure 100% what they meant in their note about 5.3. Passing and array or delimited string to parse within a function would be way to go here I guess. Thanks for your response.
  3. This may not be the right place to post this, forgive me if this should be posted in another location or this has been answered already somewhere else. Please direct me to examples if you know any, thank you. I would like to create a function that accepts a non-static number of variables. Normal Function: function myniftyfunction($var1, $var2) { -- do something here -- } That is a function that accepts two variables. What if I want to send variables that vary in number? Maybe 1 in one instance and 5 in another? The thing is at this point I do not have a maximum number I may send. This is a function I am creating for wide usage for many different scripts and applications. I can set a static number by doing something like this: function myniftyfunction($var1 = 0, $var2 = 0, $var3 = 0, $var4 = 0) {.... But whatever number of variables I set there, what happens when I have an application that needs more? Yes, I can go in and add there but my question is, is there a way to create this so that I do not have to? Make it stretchy so to speak? I don't know if there is a way to do this but I am curious if Larry or anyone else here has any ideas on how to achieve this. Thanks.
  4. Some do this with js but it could also be done with an image split up into sections using a photo editor software and using a table to arrange the split sections on page, then use hyper links to pass the version to the next page. Then you could do something like set variables everywhere content and prices would change and then pull from the database as you already are thinking. Instead of multiple IF statements to filter content I would setup a variable to pass in a database query. You would need to add a field in the database table for whatever version of content IF you were going to filter content otherwise you already have the prices setup as you explained above. A little more work but would give flexibility to the site and you would not need multiple physical pages for each version. Anyway, some more thoughts I came up with. Thanks.
  5. I have a question related to this as well. Sessions and cookies that are set via https do they follow over to http or do you need to reset the session for http? Someone logs in via https then when you direct to http are they still logged in? I don't have a way to test this yet but heard that they don't follow but I am not sure. Thanks.
  6. I notice many sites also use a visual map page that is shown when you first login, tied to a cookie so if later you come back you don't have to see the map again, that makes you select the location where you are in the world and based on that the correct version of the site is shown. This is used for language versions, prices and specific content.
  7. From the last link in my post at the bottom of that post the person gives instruction on how to show the status: Then apparently if you do this it will show the actual result Those are quotes directly from the post in that other article, I have not tried them. Let us know if those commands work for you.
  8. You will need a IDE such as netbeans an eclipse based IDE (free) or phpStorm from jetbrains (commercial). I personally use phpStorm and have Xdebug setup it connects to Xdebug via firefox in my case and steps through the code line by line, you can also set watches on variables and it makes debugging complex PHP rather simple. This is NOT possible with a text editor like PsPad etc... That is the only way I know of is to use a 3rd party IDE specifically for PHP and the walk through the code line by line as it executes. I like seeing the variables populate and see where my code breaks at which line. Makes it very easy to debug. I chose a commercial software but there are free software too, I just tested out as many options as I could and the paid software just worked better for me. Though there are other options besides the two I listed above.
  9. No worries. I didn't see it talked about here in THIS forum. Though I have not looked too deep into the other sections of the site. I am sure it is redundant info but when I get into posting mode I just like to share. Looking over this forum it seems I am sort of taking over with gabillions of posts so will probably take a break from posting for awhile. Thanks.
  10. Apparently it is possible, I found this post not too long ago at MySQL's forum. http://forums.mysql.com/read.php?98,415004,415066#msg-415066 Also phpMyAdmin has been updated on May 20th, 2011. The current version is 3.4.1 I have not used prepared statements so I don't know how well or what limitations there are or what new features the recent versions bring to that capability. Edit: It seems in the last post in that thread someone figured out how to use delimiters within phpMyAdmin to make stored procedures work and call them. http://forums.mysql.com/read.php?98,415004,415210#msg-415210
  11. I don't know either, I never tested it to see. I would assume that indexes would save on processing power as well. Also caching results, either through MySQL or outputting static files that are updated once content is added or changed. I can't know this. What if there are 40 posts for level 1 before one post is added at a higher level or 60 posts before one post at level 3 for instance. I don't know where they will be in the database, it is not a preset thing. That would be what the SQL would do for the 5 top results box, but would count upto 5 then stop. Essentially grab the first five that match the criteria. I have never written SQL that starts at the last number before, Say there are 15 matches in the database you would say start at number 5 and work back to number 1. I am not sure that is how it works, I think what happens is the database gets all the records upto a given number that match then sorts by order and ascending or descending depending if you sorted the output or not. I have heard of this tactic before. I do not know how to do it. I also do not know much about ajax, I did purchase Larry's book on building a website with ajax and I also found a couple ajax books I had here but I have not gone through them yet. I think that my idea of checking if any matching rows are within the current page and then search for additional records as needed through a second SQL query is the only option unless I just go straight to the second call from the beginning. I don't know that much about prepared statements so I don't know if those would work here or not. I think I may end up creating a cache via static files that are created from database output and then just update those pages as content changes. Some pages it is impossible to do this, such as a search page but if most of the pages are static it won't really matter I guess. I will look more into that later. Thank you for your responses.
  12. I don't have that particular book so didn't know about that. Just thought I would give an example I use, it is not the only way though. Thanks.
  13. You should be able to do a find replace in ALL files in a folder so you don't manually have to open each file one at a time. Depends on your editor or IDE you use.
  14. A quicker way is to just do a find replace, FIND -> $' or $'. REPLACE -> E' OR if you searched for $'. replace with E'. I don't know how to make the symbol so I just used E. Make sure you do this manually and look at each place it wants to do a replace on because it may not be what you want replaced. Don't do a automatic find replace all. DO NOT just do a search for $ or it will find ALL instances of variables everywhere in your code, and if there is no ' next to the dollar sign you need replaced the find wont find it. Verify in your web browser all the signs are replaced.
  15. I assume you are talking about the second site example. Page 214 ch8, in the #6 section "Print Each Item:" if you look in the example code for the line with "Price:" in it you will see the dollar sign, replace it with the EU sign. I am sure there are places in other sections of code that shows the prices, just look there and find the dollar sign and replace with the sign you need it to be. If you are going to offer both US and UK prices I would setup a variable and place it there instead and just replace the contents of the variable with the correct sign as needed.
  • Create New...