Jump to content

akitchin

Staff Alumni
  • Posts

    2,515
  • Joined

  • Last visited

    Never

Everything posted by akitchin

  1. regarding the first query (to delete duplicates from table2 that exist in table1): are you certain that the "username" columns are identical? is there a spacing difference (e.g. does one consistently have a leading or trailing space)? as for the second issue of duplicates WITHIN table2, i think some example data would help here. are you saying you want to keep any rows with duplicate usernames but non-empty email fields, while setting the duplicate username values to NULL and vice versa? if so, you may want to reconsider how you've designed your table... EDIT: thanks pikachu, i (wrongly) assumed the other thread was deleted.
  2. well, the first query should be pretty simple. you can just delete from the second table where any username is in the entire first table: DELETE FROM table2 WHERE username IN (SELECT DISTINCT username FROM table1) here is a link containing some code that will help you figure out how to remove similar records (that is, records containing a duplicate value in one column): http://www.cryer.co.uk/brian/sql/sql_delete_duplicates.htm#DeleteSimilarRecords the code he gives is to delete all similar records, while retaining the one with the lowest `uniqueField`. that's something you can change as per your requirements, depending on which record you want to keep in case of duplicate values. you can run the first query, followed by the second and third in whichever order you choose to. hope this helps.
  3. my mistake - I should have looked at the HTML form. since your dropdown select box is named "category_selection", you should be able to use: if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission")) { switch($_POST['category_selection']) { case 'Web_sites': $table_name = 'partner_sites'; break; case 'Blogs': $table_name = 'partner_blogs'; break; case 'Directories': $table_name = 'partner_directories'; break; } $insertSQL = sprintf("INSERT INTO `$table_name` (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['url_field'], "text"), GetSQLValueString($_POST['title_field'], "text"), GetSQLValueString($_POST['anchor_field'], "text"), GetSQLValueString($_POST['description_field'], "text"), GetSQLValueString($_POST['webmaster_nane_field'], "text"), GetSQLValueString($_POST['webmaster_email_field'], "text"), GetSQLValueString($_POST['category_selection'], "text")); mysql_select_db($database_content_conn, $content_conn); $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error());
  4. you still haven't explained why exactly you need the "value" of the checkbox... can we see the code that produces the HTML form?
  5. what did you name the dropdown element? should you not be using that to determine which table to insert the info to? my point was that $_POST['site_type'] might be set, but $site_type wouldn't be unless you assigned it manually.
  6. what are you using the checkboxes for here? if you need the values in the unchecked checkboxes, then presumably your choice of element is incorrect.
  7. first off, you could save yourself a lot of space by simply switch()ing on the $site_type to change the table name, and assign a single query: if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission")) { switch($site_type) { case 'Web_sites': $table_name = 'partner_sites'; break; case 'Blogs': $table_name = 'partner_blogs'; break; case 'Directories': $table_name = 'partner_directories'; break; } $insertSQL = sprintf("INSERT INTO `$table_name` (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['url_field'], "text"), GetSQLValueString($_POST['title_field'], "text"), GetSQLValueString($_POST['anchor_field'], "text"), GetSQLValueString($_POST['description_field'], "text"), GetSQLValueString($_POST['webmaster_nane_field'], "text"), GetSQLValueString($_POST['webmaster_email_field'], "text"), GetSQLValueString($_POST['category_selection'], "text")); mysql_select_db($database_content_conn, $content_conn); $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error()); } second, i would guess that the issue with your code is the use of $site_type. where is this variable coming from? since you're accounting for QUERY_STRING i'd assume it's coming from the URL. if so, then you still need to access it using the $_GET superglobal.
  8. i'm going to take a wild stab here and say that it's because you're trying to check for matches against "", an empty string... unless i'm missing something? preg_match_all
  9. your issue is greediness. patterns are by default greedy in the PCRE functions in PHP. what this means is they will match the LARGEST POSSIBLE pattern. since you have (.+) in your pattern, that means that this whole thing: "http://images.4chan.org/adv/src/1288558759794.png blah blah http://images.4chan.org/sci/src/" will be matched, since "adv/src/1288558759794.png blah blah http://images.4chan.org/sci" matches the (.+) subpattern you have in there. use the question mark after your quantifier to make it ungreedy by default: otherwise you can use the U modifier at the end of the pattern: EDIT: AbraCadaver's post will also work.
  10. i would guess the issue with your original code is that move_uploaded_file cannot use URL wrappers in the location. try changing your target to use the filesystem's directory location.
  11. it's tough to answer your question, since we have no idea how your session is currently structured or how/where you set the original $_SESSION values. could you not simply use: $_SESSION['bio'] = $bio; to rewrite with the new $bio information? you don't necessarily have to "reset" the session, you can simply overwrite the current variables with the new information.
  12. this probably has to do with flash more than anything. $_SERVER['HTTP_REFERER'] shouldn't be relied upon, since it can be spoofed by the browser. however, can you be more precise as to what flash means by sequence error? if it means that the headers have already been sent, then it means that there is output from the PHP file before the attempted header call, which is a very common error. the problem is, without knowing what your file structure is like (ie. what gets called by what file and when), it's difficult for us to track it down for you.
  13. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=313766.0
  14. please use code tags in the future. also, even though your question is simple, it would be helpful to actually WRITE the question into the post, rather than just posting your code and assuming everyone knows what you want to achieve. i'm moving this to the javascript board because this is more of a javascript question. look into the "onClick" event and the "disabled" attribute of the input element.
  15. based on the code you posted, you hadn't changed anything to match... if it's still not working (even after Andy-H's latest suggestion), can you paste what you have in your file?
  16. glad it helped - i didn't realize there were two spaces between each data set, i suppose the BB code might have stripped that out. i should mention that if you yourself wrote the script to write to the log file, it might be more handy to use serialize to compress the data that forms part of the error, strip that whole chunk out somehow (perhaps using a set delimiter), and use unserialize to break that data back out into variable form. then again, if this method works just fine now, no need to mess with it. just a thought for future applications.
  17. unfortunately i'm not that knowledgeable on performance issues, so i couldn't tell you off the top of my head. you could test by getting a JOIN query that works and running that against this sub-query method a few times. sub-query tutorials on the rest of the internetz might also include performance in their discussion. if fenway sees this thread i'm sure he will be able to offer an expert answer .
  18. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=313729.0
  19. if you just copy-pasted it without editing it to suit your script's current setup, that's not surprising. let's see what your code is currently (including the part you just inserted from Andy-H's post).
  20. in that case, you might be able to use a look-ahead assertion, which allows for two cases: 1. the closing single-quote in the category value subpattern must be followed by a " '" (space then single-quote) to capture all of the middle data sets, and 2. the closing single-quote in the category value subpattern must be followed by a "." (period) to capture the last data set. give this a shot. i'll admit i haven't tested it, i simply constructed it from the PHP manual entry on Assertions (click to view): "/ '(.*?)' Merchant value: '(.*?)' catalog value: '(.*?)'(?= \'|\.)/i" there is mention of the look-behind assertion needing to match strings of the same fixed length, but i don't know if the same holds true for look-ahead assertions. hope this helps.
  21. fancy! that's what i get for not keeping up-to-date on the newest PHP5 functions.
  22. have a look on this website for explanations of the type of regular expression pattern you'll want to use in each case: E-mail validation List of phone number and address patterns for the second link, scroll through the list to see what sort of format you want to enforce.
  23. it looks as though every value will also be encased in brackets. could you not add those to the pattern? "/ '\[([.*?)\]' Merchant value: '\[(.*?)\]' catalog value: '\[(.*?)\]'/i"
  24. IN is actually a handy operator - you supply it with a comma-delimited list of items, and you can specify that a column's value be a part of that list, or not (as in this case). MySQL manual entry
  25. this sounds like an apt job for a subquery. you could try something like this: SELECT * FROM videos WHERE video_id NOT IN (SELECT video_id FROM videoViews WHERE user_id='$user_id') ORDER BY RAND()
×
×
  • 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.