Jump to content

akitchin

Staff Alumni
  • Posts

    2,515
  • Joined

  • Last visited

    Never

About akitchin

  • Birthday 11/01/1985

Contact Methods

  • Website URL
    http://www.akitchin.com

Profile Information

  • Gender
    Male
  • Location
    Calgary, AB, Canada

akitchin's Achievements

Regular Member

Regular Member (3/5)

1

Reputation

  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?
×
×
  • 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.