This function doesn't seem to work with D5.1. First problem is that {contact}.cid is an auto_increment field, so there is no reason to use db_next_id. Second, not sure why in the VALUES declaration, values are being equated... looks like VALUES is being treated like a function. So, I propose the following fix:

Change this:

function install_contact_add_category($category, $recipients, $reply = '', $weight = 0, $selected = 0) {
    $cid = db_next_id("{contact}_cid");
    db_query("INSERT INTO {contact} (cid, category, recipients, reply, weight, selected) VALUES (%d, category = '%s', recipients = '%s', reply = '%s', weight = %d, selected = %d)", $cid, $category, $recipients, $reply, $weight, $selected);
}

To This:

function install_contact_add_category($category, $recipients, $reply, $weight, $selected) {
db_query("INSERT INTO {contact} (category, recipients, reply, weight, selected) VALUES ('%s', '%s', '%s', %d, %d)", $category, $recipients, $reply, $weight, $selected);
}

Much simpler.

Comments

boris mann’s picture

Assigned: Unassigned » boris mann

Probably cut and paste errors. Thanks.

dmitrig01’s picture

Component: Code » crud.inc
Status: Active » Closed (duplicate)