The above code works fine if it is in a separate file but when incorporated inside a file with other sqls, only the update statment works. I have for the past few days trying to identify the problem with no success.
How about using a REPLACE INTO statement? Or INSERT INTO ... ON DUPLICATE KEY UPDATE ... The second may be better as you're referencing existing data for an update, which won't exist in the first example as the record is deleted then written (I think). However the difference in both sql statements means that this may not be possible. What about querying for an existing id (SELECT) if it exists - UPDATE, else INSERT. This…
When the sql is echoed, nothing is displayed. It appears that the insert statement is skipped if the "if statement" that calls for it is true. Running the statement directly through phpmysql works fine with no errors.
Try, changing either $result to something else e.g. $result2 .. I think your scripts is just experiencing a minor naming collisions when integrated each other. Is this script will be running on production server? If yes, can you at least hash those CC numbers even at the minimum.. I don't know, but it is just so tempting for someone to make your script throw up all those numbers. Before considering any hashing and securing credit numbers for database storing, please read this white paper about it.
I am sorry for being such an A__ , I can't help it, whenever someone is posting script that has a lot of personal info. in it.. I just can't stop from crinching..
veedeoo, thanks for chiming in. I have previously tried different names with the same thinking --concerning collision. this too did not work. I just gave it another try, still no luck. Thanks for your concern about the integrety of the data. Fortnuately the information in the code does not have any credit card information.