Jump to content

Psycho

Moderators
  • Posts

    12,157
  • Joined

  • Last visited

  • Days Won

    129

Everything posted by Psycho

  1. You main problem is that your database design is flawed. You should have an intermediary table to associate users to groups. The table would only need two columns: user_id and group_id. You would have one record in that table for each association. So, if a user belongs to two groups there will be two records in that table. However, if you really must keep your current flawed approach, you don't need regex. A simple LIKE comparison would work fine as long as you make sure there is a period at the end of the value in the user_groups field - ex: ( .1.3. ). Then you query would be thus: $groupID = mysql_real_escape_string(trim($_POST['sendto'])); $query = "SELECT * FROM ".DB_USERS." WHERE user_newsletter = 1 AND user_groups LIKE '%.{$groupID}.%'";
  2. Could the problem be that you should be using an AND in the comparrison instead of an OR. You state in your post So, do both values have to be set for the user to be considered logged in? If so, you should be using AND instead of OR.
  3. I know I've seen an example of this somewhere, but to be honest it would be foolish to implement in my opinion. To accomplish this you would have to create a workaround to the browsers default handling of password fields or use some sort of hack to a regular input field. You might get it to work in most, or maybe even all, current scenarios. But, for a password input even one failure would be unacceptable to me. The consequences would be either the password would be displayed in plain-text (kinda bad) or the password the user thinks they types gets mangled somehow which would prevent them from logging in (really bad).
  4. I think what you want to do is give the select statements a name such that they will be returned as an array with the team ID as the index. Here is what the HTML output would look like: Team 1 <select name="team_points[1]"> When you create these in PHP I would assume you are looping through the teams and writing the data. The PHP code would look something like this: echo "$teamName <select name="team_points[$teamID]">"; In the processing page you can simply loop through the POST array value to get the team IDs and Points submitted foreach ($_POST['team_points'] as $teamID => $teamPoints) { echo "Team ID: $teamID, Team Points: $teamPoints <br> "; }
  5. That was the first hit in the link I posted above and the author states which would indicate they may be good enough for some uses. The only other option would be to have a full-featured image editor installed on the server and use command line functionality to convert the images.
  6. I think you should look at ImageMagik which is supported with PHP. I believe it has the capability to convert an image from CMYK to RGB. Not 100% sure: http://www.imagemagick.org/script/index.php
  7. A simple google search for "php cmyk to rgb" brings up some good results. http://www.google.com/search?hl=en&q=php+cmyk+to+rgb&aq=0&oq=php+cmyk&aqi=g1
  8. You're still not explaining what the "selection" is for. Let's assume you can select multiple text fields. What then? If you explain what the purpose is, then it helps to provide a solution. The only purpose of selecting multiple fields in an excel table that I can think of would be to delete the data in all the selected cells or copy the data.
  9. About the dash, you are right, but it's easier for me to remember to always escape it (like I have to do for other characters) than to remember a special rule for it. Either way works. As for the locale and the character classes, that's a new one for me. Never ran into that problem before.
  10. You had better also implement 9three's suggestion as well or that test will not work as you expect. The first two tests would cancel themselves out (because one would always be true)and only the last test would determine if the output is true or not. Unless you group conditions together they are interpreted from left to right including the AND/OR's. This is what you have: Test1 OR Test2 AND Test3 In processing the code each test is checked individually Then the AND/OR are used - again from left to right. So, it will first check if Test1 OR Test2 are true. Since they are opposites of each other that test will always return true. Then the next step it to compare the result of the Test1/test2 comparison with Test3. So you end up with TRUE AND Test3 So, the result of your test will end up being the result of Test3. you need to group the conditions as 9three suggested
  11. The dash and dollar sign needed to be escaped. preg_match('/^[A-Za-z0-9_][A-Za-z0-9_.-@#$!]{4,49}$/', $username) Edit: You can simplify that by using the character class \w which is the same as [A-Za-z0-9_] preg_match('/^[\w][\w.-@#$!]{4,49}$/', $username)
  12. If you aren't sure about what special characters need to be escaped, it would have taken about 5 minutes to verify for yourself. Just create the regex with simple alphanumeric checking then add in one special character at a time and test accordingly. I see that you posted about an hour ago. I'll go test this myself after I submit this to see how long it takes for me to figure it out through trial and error.
  13. Math? Yes, there are plenty of math functions, but what you need is logic to create that functionality. I'm assuming that in your example the last set of ellipses are not part of the output you want and the example represents what you would see when the current page is page 8? So, it always shows first three pages, the current page with prev/next and then the last three pages. So, on page 7 it would look like this? 1 2 3 ... 6 7 8 ... 13 14 15 That's not too difficult, but you need to decide what happens if the user is on one of the first/last few pages or if ther are only a small number of pages
  14. You need to be more specific. I think I understand your first questionabout making the secondary lists appearing AFTER you make a selection in the parent. You just need to set the display or visibility values as none or hidden respectively. Display and visibility are treated very differently based on form submissions so you would need to determine which is correct. As long as you will only allow the user to submit after all have been displayed it won't matter except that display will make content move on the page and visibility will hide the elements but not shift the other content. But, I have no idea about the second part of your request. The form fields are automatically available to PHP on submission as long as you have a proper form. And what do you mean about the last variable appearing after clicking a submit box (er. button?)
  15. So, you want us to explain to you in a forum post what you are not understanding from a tutorial? I'm not even clear on what you want to know based upon your post. The title and the beginning of your post implies you need info about creating a zip archive. But, then you specifically ask about what to do with the files that are uploaded. I'm not sure what that has to do with zip archives. Are you saying that you want to create a zip archive of the uploads based upon month? That is up to you and has nothing to do with the functionality to "zip" the files into an archive. However, the logic to select the right files would be easier if the files were already grouped into folders based upon the ones you woulod want in an archive. But, YOU need to decide if that is appropriate for all the ways you may use these files. When you create an archive you will use the appropriate logic to determine which files to add to the archive. This could be by including all files in a folder, by file name, by database attributes, etc., etc. In other words, we can't answer this for you. Putting all the files in a folder by month sounds like a good idea to me, but without knowing ALL the usages for these files that is just a guess.
  16. That wasn't what you asked in your original post. Sorry, but it irks me when someone asks for something and then when given what they ask fo, then asks for something different. You need to clarify exactly what you want by the "multiple selection" of cells within an HTML table? What do you want to be able to do once these are selected? I suppose it would be easy enough to "highlight" cells in a table in such a manner, but they wouldn't be "selected". Need more info because I don't think what you want to do can be achieved with Javascript and an HTML table. May have to go with a CSS table and some backdoor trickery. In otherwords it would probably have compatiblity issues.
  17. Here is all you need SELECT a.album, p.photo_url FROM albums a LEFT JOIN photos p ON a.album = p.album GROUP BY a.album The JOIN will get you a record for each album/image combination. But, by using a GROUP BY you 'collapse' the records down to one row for each albim and only the first image will be associated with it. If you needd a particular image associated with each album you can use an ORDER BY on something like the photo name. Or you could have a column in the photo table to identify the photo to be used for the album photo. Then just use a where clause. As long as you have a one to one association you wouldn't need a GROUP BY.
  18. Here you go. Note that the alerts in the script "traps" the shift down state. So, if you release the shift key while the alert is on screen the code still thinks the shift key is down. I only put those in for demonstration purposes. This shouldn't be an issue if you aren't using an alert on whatever action you are taking in those scenarios. If you are using an alert I would change the shiftKeyDown state to false whenever you trigger one of those states. <html> <head> <title>test</title> <script type="text/javascript"> var shiftKeyDown = false; function detectShiftArrow(e) { e = e || event; if (e.type=='keyup' && e.keyCode==16) { shiftKeyDown = false; } else if (e.type=='keydown' && e.keyCode==16) { shiftKeyDown = true; } else if (e.type=='keydown' && shiftKeyDown) { switch (e.keyCode) { case 37: // Left alert('Shift left arrow'); break; case 38: // Up alert('Shift Up arrow'); break; case 39: // Right alert('Shift Right arrow'); break; case 40: // Down alert('Shift Down arrow'); break; } } } </script> </head> <body> <input type="text" name="1" onkeydown="detectShiftArrow(event);" onkeyup="detectShiftArrow(event);" /> </body> </html>
  19. Doesn't anyone ever read the documentation anymore? No offense, but you apparently just started using LIMIT without even checking what the parameters mean. The first parameter indicates the starting record (first record is 0). The second parameter is the number of records to return, NOT the last record to return. LIMIT 0, 10 This will return 10 records starting at record 0 (i.e. 0 - 9) LIMIT 10, 20 This will return 20 records starting at record 10 (i.e. 10 - 29) LIMIT 10, 10 This will return the 10 records starting at record 10 (i.e. 10 - 19). So the limits for your pages (assuming 10 records per page) would be like this: Page 1: LIMIT 0, 10 Page 2: LIMIT 10, 10 Page 3: LIMIT 20, 10 etc...
  20. There was only one curly brace that was missing. You don't have to encapsulate else/if code if it is only on one line. Anyway, you need a closing curly brace after the line "Your credit card is valid". There are two other errors: 1. The enctype value for the form is messed up. It needs to be corrected and, ost importantly, end with a double quote mark. 2. On the input field for the CC number you have code to repopulate the field, but you put the value AFTER the closing quote mark. The PHP needs to be inside the quotes, like so: <p><input type="text" name="ccnumber" size="20" value="<?php if(!empty($_GET['ccnumber'])) echo $_GET['ccnumber'] ?>" /></p> because you had an opening bracket withut a closign bracket. So the PHP parser went to the end of the file and didn't find the closing bracket.
  21. Make sure you look at the examples on the page that Q linked to. You need to use a combination of ucfirst() AND strtolower() to get what you want - unless the values from teh DB are always in lower case to begin with. But, just look at the examples and there is one exactly for what you need.
  22. Psycho

    Help

    Ok, the process should be fairly strait-forward. If you want "help" on doing this yourself, then this is the place to get it. however, if you want soemone to "do it" for you then you need to post in the freelancing forum. You make the call. But, I can provide an overview of how I would accomplish this: 1. Read the file using file() so the results is an array with each element of the array as a different line of the file. 2. Create appropriate logic and egex expressions to extract the data for each column into a mutidimensional array. 3. process the array to either insert/update records in the database as needed
  23. Psycho

    Help

    Is the page you linked to in your original post "THE" document you are getting the data from or is there a different document which you used to create the HTML page? If it's a different document, please attach the file. Also, there are two different tables - do you need the data from both tables or only one?
  24. A better question is how to get your data into a better format to begin with. Instead of having allt he folders/files in a signle array and having to use string manipulation the data shoud be in a multidimensional array. Edit: I posted a function, but had to withdraw as I need to review it.
×
×
  • 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.