Jump to content

gizmola

Administrators
  • Posts

    5,945
  • Joined

  • Last visited

  • Days Won

    145

Everything posted by gizmola

  1. This is the type of thing where it would probably just be better to do this in a bash script, if the idea is that you want to mount the shared drive, test for the existence of a file, email if it's not there, and then unmount it.
  2. Ok... not much that I can suggest then. With that said, I don't see you specifying the character set.
  3. There was nothing rude about my reply. Since you misunderstood what I wrote, perhaps you also misunderstood what I wrote about the ORDER BY. I did not say that the order by could effect the result set. Only that your use of it might lead to your perception that something is wrong. You also missed the main point which is, that you continue to post sql and neglect to post in data from the result set that shows what you mean when you claim it is out of range. A describe of your main_table wouldn't hurt either. Feel free to google mysql curdate if you are interested, as an article I wrote almost 7 years ago about using it with DATE_ADD is still in the first page of results, so I would have to say this is an area of mysql functionality I understand better than most
  4. You should not be calling mysql_num_rows() twice in a row. $num=mysql_num_rows($query1_exec); echo ' '.$num.' '; if (mysql_num_rows($query1_exec) == 0) Change this to: $num=mysql_num_rows($query1_exec); echo ' '.$num.' '; if ($num == 0)
  5. When you say it "seems to be" that's where you probably don't realize that you didn't provide us any information about the result set. I will go ahead and state the obvious then, that if you use OR, the condition simply needs to be valid on either date_one or date_two for it to come back in the result set. Since you ORDER BY date_one at the end, this might explain your confusion, because a row could match the date_two but have a date_one that is far in the future. That's the nature of the query you have created.
  6. I can only suggest that you use the method kenrbsn suggested to make sure that the arrays you're iterating through are what you expect them to be. You might want to post the latest version of your code as well.
  7. At some point during runtime the arrays you create using preg_match_all might become invalid because there was no match. You can try to add some error checking above, so for example: if (is_array($city)) { // go head }; See if adding that check prevents the runtime error.
  8. Check the note from yuricardenas in the comments on this page: http://us.php.net/manual/en/book.gettext.php
  9. There is no problem using a self posting form. If the form exists by itself, it actually solves a lot of problems. Most forms do not exist in a vacuum however -- they exist within the ecosystem of a larger web application, and for that reason, people use frameworks that typically employ the MVC pattern, and in that case a form is like any other view, only more complicated because you have the issues of data cleansing and validation. My suggestion would be to look at the mvc and form classes of zend framework or symfony and look at how they have approached the problem. With that said you can extrapolate answers to your question looking at my reply to this thread http://www.phpfreaks.com/forums/index.php?topic=325765.msg1535081#msg1535081
  10. Nobody can help you when you provide the code from the part that works, but leave out the code that doesn't. For what it's worth, this query will never be able to use an index. It will table scan through the entire users table every time you do a search. That might not be a problem for you if your user database never gets too large, but I thought I'd mention it. First off you don't need to use upper($field) because mysql indexes are already case insensitive. Using upper() will cause a tablescan, however, so will LIKE '%something%';
  11. Turn your form into a php script. I'm going to assume you name it form.php. You'll leave it as is, but inside the body you'll want to add something like this at the top: 0)): ?> </pre> <ul class="error"> </ul> <b Your current script will become the script that is called both to display and process the form. The basic pseudo code needs to be: $postdata = array(); if (isset($_POST) && validateform($postdata, $errors)) { // send email code using cleaned data in $postdata array // redirect to success // exit(); -- You always want to exit after a header(location...) to prevent people from trying to exploit your script } require_once('form.php'); So hopefully you understand that what will happen is that when the script starts, it will check to see that there is data in the $_POST and then your validateform() function will need to check for errors. Any errors it finds it will add a message to the array $errors. You need to declare the $errors array to be passed by reference. If there is no $_POST data OR the form has post data but fails validation it will fall through and display the form, because it's required at the bottom. When the form passes validation, you will process, redirect and exit, so that the form is never displayed. In the process of validation you'll build the array $errors. Any $errors that exist will be picked up in the form code and displayed in a ul at the top. This is the best practice because you want to alert the user to all the errors you found so that they have all the errors shown to them immediately rather than fixing one only to stumble on the next. You can also add usability to your form by using the $_POST[] variables to set the values of the form elements. That way if they make mistakes, their prior entries will already be filled in, so they don't have to rekey all the data into the form. function validateform(&$postdata, &$errors) { // move in your code here that calls your check_input() function. Return your sanitized data to the $postdata array that you pass by reference to it. // example: $postdata['email'] = check_input('email', 'Please enter your name', $errors); ' // add the others return (count($errors) > 0); } Notice that I don't pass in $_POST because it is a superglobal and doesn't need to be passed to a function. It's already global. You can just pass the key name. function check_input($key, $problem='', &$errors) { $data = trim($_POST[$key]); $data = stripslashes($data); $data = htmlspecialchars($data); if (strlen($data) == 0) { $errors[] = $problem; } return $data; } This is roughly what I might do given your existing code. It's not really the best structure, because check_input really doesn't allow for you to implement any customized validation rules, but once you get the basic skeleton together and see how to implement this you can always improve on it.
  12. Your design for this feature is just hopelessly wrong. Did it not occur to you that 2 people might attach a file with the same name? As for why your current code doesn't work, this doesn't seem to be complete, because you start a loop based on the explode of the list of attachment names (bad design... see "repeating group") that never gets ended in the code you provided. I really don't know why it is that since you even made an attachment table, you didn't just go the extra yard and have the post id, be a foreign key in that table.
  13. Then why are you here? This is a forum to help people who are trying to help themselves learn php.
  14. If you provide an html format body with the email then you handle a url like any webpage --- via an anchor tag. Whether or not the email client will support html is entirely controlled by the email client -- email is not a web browser. With that said, most email clients will support simple html, and they also tend to support recognizing that url's which start with http:// should be converted into links.
  15. Welcome. Actually talking to people is much better than lurking
  16. The typical way that is done is to use mod_rewrite rules, assuming you are using apache. You also need some functional code that will translate an internal url you generate into a "rewritten" url, so that when you display links to locations in your site, they are presented in the SEO way. In order for this to work, your site needs to have a url scheme in place where rules can be installed. For example, you need something like: ?module=articles&action=show&slug=3-My-Site-is-launched So that the rewrite rules can effectively break up your seo friendly url by position, and fill the module/action and id parameters from the SEO friendly url of: http://yoursite.com/articles/show/3-My-Site-is-launched There are lots of examples of making this work, not to mention that near every forum,blog and cms come with htaccess files that have robust implementations of these rules you can learn from by example. Mod_rewrite rules require a basic understanding of regex, but there are countless tutorials around.
  17. Well you have 2 files with the same function declared. This is why you're getting the error. Comment out the function in one or the other of the include files.
  18. cssfreakie really captured a lot of the things I've been saying. As I mentioned previously, one sign of a bad site is inconsistent typography. Another is random colors, which is something your site currently suffers from. I can elaborate with one other tool that is helpful: http://colorschemedesigner.com/ You pick colors you like and it lets you play with different schemes using color theory to determine which colors go nicely together. As for Joomla and Drupal, they are written in PHP so you can code customizations, but you probably would not be needing to do much if any. The templates themselves are a mix of html and php, and in my experience that is where you would most likely need to do a little php tweaking. The main reason I brought those up, is that the ultimate goal seems to be for you to provide a site that the club can maintain over time, and one that is static html and php with a few include files that you have to hand edit most of the time, is not going to provide that. Once that occurs there will be pressure on you to provide a solution that allows the members to update content, and pretty soon you'll be writing your own cms. Learning either CMS still requires a substantial investment of time, but purely based on the type of site you have, I would probably look at using Joomla 1.5x, possibly with the K2 CCK plugin. For the most part your exercise would be getting it installed, and from there configuring the site to have the layout and blocks you want. You probably should do a test install and try and move over your current site, just to see how what would be involved.
  19. Yes it's similar to googlecode or sourceforge.net. It just happens to use Git as the source code mgmt system.
  20. It's 100% subjective. As for a top menu, you really want to have that. It's not necessary for you to have every item you have in your sidebar menu -- you can pick out the most important items. Here's a site for a club in the LA area that might provide you with a bit of inspiration. http://www.valleyflyers.com/ Now it was developed by a guy who has a web design company, but the underlying ideas used are the same ones we've been discussing in this thread. In his case he used a 3 It has to be said, that the valleyflyers.com site is using some sort of CMS. There's a point at which a site like yours needs to consider using Joomla or Drupal for long term maintenance, and so that the various people involved with the club can update content. It's probably better to figure that out sooner than later, because CMS templates have a specific structure to them. Also, there are marketplaces where you can go and buy a template for anywhere form $10-100 and customize it to your needs.
  21. I'd recommend you use this site. One big advantage is that they already have navigation and you can also choose from a variety of different skeletons. You have to decide whether you want a liquid layout, that expands and contracts with the browser size, or a fixed width display. For a site like yours, one advantage of a fixed width display is that you can put a background image behind it, and being that your site is a hobby club, a picture, perhaps with reduced opacity or tweaked with one of the photoshop filters, might be a nice touch. http://www.maxdesign.com.au/articles/css-layouts/
  22. I can't really understand your schema or the joins based on the information you provided, but the way to solve this is this: Do an inner join of employee to classes, in whatever way you need, and only select the employee id. Add a GROUP BY or DISTINCT so that you only get one row per employee, but this will be the list of employee ids WHO TOOK A CLASS. Now you convert this into a subselect using NOT IN or a LEFT OUTER JOIN that self joins employee to this result set by ID. Include an extra column that you can then filter using WHERE IS NULL. You might want to try the subselect first as it's easier to understand that syntax usually. Select employee.... FROM employee WHERE id NOT IN (SELECT ..... inner join of tables to get result set of employees who took a class).
  23. I'm not sure why you're trying to mix session variables into this. Make a simple form with whatever it is you're trying to submit on it. In your order_summary read the data from $_POST[].
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.