delete statement isn't working... why?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

Post by vincenzobar »

Warning: array_map(): Argument #2 should be an array in /home/vincenzoba/domains/underwaterdesign.com/public_html/xml/output-rate.php on line 98

Warning: implode(): Bad arguments. in /home/vincenzoba/domains/underwaterdesign.com/public_html/xml/output-rate.php on line 99
('', '')Column count doesn't match value count at row 1
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

there you go :)

1) there's no reason to use array_map() the way you were
2) implode() should be obvious
3) Shiz hit that one on the head, define your cols when you do an insert.
vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

Post by vincenzobar »

there are 28 columns and 29 in archive

array map is to add a \ to ' in the insert values nothing else worked

all values add up to columns so there should be no need.

it runs fine for 120 inserts then stops and produces that error, why after 120 inputs?
vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

Post by vincenzobar »

also, when i comment out the delete statement it goes through fine.

WHY GOOOD WHYYYYYYYYY
vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

Post by vincenzobar »

The error comes when there are duplicate product ID in the table.

so if the datadump XML sheet has say 20 duplicates of P-id 12345 then it dies.

This is good and bad. Good because it shows there is an error in the dump. bad because it fails to continue the rest of the script so if i get a bad dump it could mess up the whole table.

I guess i need to add a check like if row is there more than once then delete all duplicates.

Anyone know how i should go about this?

Anyone know any short cuts for this???

thanks for all your guys/gals(if any here) help!!!

your the greatest!
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

vincenzobar wrote:I guess i need to add a check like if row is there more than once then delete all duplicates.
Delete where :?:
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post by Jenk »

If you are wanting to delete duplicates from the array, then use array_unique()
vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

Post by vincenzobar »

after much studying of the XML file it turns out that they are not REALLY Duplicates. The only difference is that the "rateplanid" is different.

Howerver this is causing a problem on delete because i am deleteing where productid is the same and for some reason as soon as it hits a duplicate id the array breaks and i get all the warnings above.

is there code that will realize this fact or is there a way to delete where product id match DB and XML Dump for every rateplanid that exists with XML product id.... i know confusing...

here is the output and as you can see it goes to delete something that isn't there... i think how do i get around this. BTW, i tested this script on another file without rateplan and it worked perfectly.
DELETE FROM CB_rateplan WHERE productid = 53643;('', '121', 'US Cellular National Plan w/ 1200', '1200', '59.9500', '0.4000', '0', '0', 'included ($0.00/min)', '24', '$150.00', '', '', '0', '', '0', '', '0', 'included ($0.00/min)', '', '', 'monday - friday 9:00pm to 6:59am; weekends friday 9:00pm to monday 6:59am', '', '53639', 'u.s. cellular', 'images/carriers/', 'uscellular_l.gif', 'false', '13821')

DELETE FROM CB_rateplan WHERE productid = 53639;('', '122', 'US Cellular National Plan w/ 2000', '2000', '99.9500', '0.3000', '0', '0', 'included ($0.00/min)', '24', '$150.00', '', '', '0', '', '0', '', '0', 'included ($0.00/min)', '', '', 'monday - friday 9:00pm to 6:59am; weekends friday 9:00pm to monday 6:59am', '', '53641', 'u.s. cellular', 'images/carriers/', 'uscellular_l.gif', 'false', '13857')

DELETE FROM CB_rateplan WHERE productid = 53641;
Warning: array_map(): Argument #2 should be an array in /home/vincenzoba/domains/underwaterdesign.com/public_html/xml/output-rate.php on line 99

Warning: implode(): Bad arguments. in /home/vincenzoba/domains/underwaterdesign.com/public_html/xml/output-rate.php on line 100
('', '')Column count doesn't match value count at row 1
vincenzobar
Forum Commoner
Posts: 95
Joined: Wed Nov 02, 2005 9:57 am

Post by vincenzobar »

nevermind i just made a script for each XML File. one sorts by product id for equipment and the other sorts by rateplanid for rate plan. Basically it needs to be a unique key i guess

thanks for all the help!!!

I'll be back!! *Arnold voice*
Post Reply