Sukrit Jaie
Sukrit Jaie

Reputation: 23

Error on inserting data to foreign keys

Can someone please help me I'm stuck with this for quite some time and am quite new to this as well. I have a table(tbl_call_log_detail) that contains 2 foreign keys(dealer_id referencing id in tbl_dealer_info and type_of_call referencing id in tbl_call_types). I'm trying to update my form, which works correctly. Then I want the relevant fields from the update to insert to tbl_call_log_detail automatically. This is what I'm losing my mind over

$query = "SELECT id FROM tbl_dealer_info WHERE account_name = '$account_name' INTO $dealer_id";
    $result = mysqli_query($conn, $query);
    $query2 = "SELECT id FROM tbl_call_types WHERE type_of_call = '$type_of_call' INTO $type_of_call";
    $result2 = mysqli_query($conn, $query2);

        $sql = "INSERT INTO tbl_call_log_detail ";
        $sql .= "(comment, time_stamp, type_of_call, dealer_id) ";
        $sql .= "VALUES ";
        $sql .= "('$_POST[comments]', '$_POST[time_stamp]', '$type_of_call', '$dealer_id') "; 
mysqli_query($conn, $sql);
}

When I echo my Insert statement and then copy paste it on phpmyadmin, I get the error

'Incorrect integer value: change in region' for column 'type_of_call'

Upvotes: 0

Views: 38

Answers (1)

Mayank Pandeyz
Mayank Pandeyz

Reputation: 26258

'Incorrect integer value: change in region' for column 'type_of_call

here type_of_call in an integer column and you are trying to insert 'change in region', a string value in it.

Upvotes: 1

Related Questions