+ Reply to Thread
Results 1 to 4 of 4

Thread: Small script needed

  1. #1
    jhsands Guest

    Default Small script needed

    Can anyone help me with a small script? PHP or Perl is fine.

    Database: allisons_osc1
    Table: products_groups
    field: customers_group_price


    Need to delete all entries that = 0.0000 in field customers_group_price

    THX
    JHS

  2. #2
    PsyCHZZZ's Avatar
    PsyCHZZZ is offline aspiring dreamer~
    Join Date
    Dec 2006
    Location
    Tokyo, Japan.
    Posts
    142
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi... I'm assuming that you just want to run this like once right? If that's the case, why not just do it from MySQL itself? The command in MySQL for a delete is pretty simple.

    In your case,

    USE allisons_osc1;
    DELETE FROM products_groups WHERE customers_group_price='0.0000';
    That will remove all entries in the specified table that the WHERE command satisfy.

    If you still need the script then just post here... I think I might be able to help out. Cheers~

  3. #3
    jhsands Guest

    Default

    I have to run it everytime after I enter a set of new products.
    A bug somewhere in osCommerce SPPC... so the script would be much appreciated!

    P.S. to everyone else that tries the above or below, be sure and make a backup copy of your database. Screwy things can happen and you can save yourself a whole lot of headache by having a database backup.

    I learned that about two years ago
    Last edited by jhsands; 11-20-2007 at 10:17 AM. Reason: backup

  4. #4
    PsyCHZZZ's Avatar
    PsyCHZZZ is offline aspiring dreamer~
    Join Date
    Dec 2006
    Location
    Tokyo, Japan.
    Posts
    142
    WHB Points this Month
    0.00
    WHB Points
    0.00
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ahh.. ok. In that case, here's the script then.

    It's pretty straight-forward. Database connection details are on the top of the page so you gotta set the username/password yada yada...

    The script is meant to be viewed using a browser as I made a confirmation screen before deleting so that you can see how many number of rows will be affected and the records that will be removed.

    There's 2 statements "$selquerystr" and "$delquerystr" that will be executed; just modify them as you deemed fit.

    I bet you already know this but this script can be run by anyone who can get accessed to it (since there's no authentication prior) so, keep it in a cool dry place safe from prying eyes

    Cheers~

    P/s:
    You gotta rename the file to .php since the upload attachment cannot accept php extension.

    IF you just wanna run it from the prompt and do not need the confirmation, just edit the file and delete the entire // main body portion and only keep the "// proceed with delete" portion and the "//display result(s)" just to show some output.
    Attached Files Attached Files
    Last edited by PsyCHZZZ; 11-20-2007 at 10:19 PM. Reason: Added additional footnotes

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts