Incorrect integer value: '' for column 'compid'

:joy: its on my list of to do’s. I’ve just got a couple of projects i need to get sorted first lol.

Thats what i originally had it set at though. Now im confused lol.

<select type="text" name="compid" class="form-control" value="<?php echo $compid; ?>">
						<option hidden>Select Company</option>
/ Check input errors before inserting in database
    if(empty($fname_err) && empty($lname_err) && empty($email_err) && empty($contactno_err)){
        // Prepare an insert statement
        $sql = "INSERT INTO contacts (compid, fname, lname, title, email, contactno, mobileno, role, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)";
         echo "Hey Oli! I think my compid is:".$compid;
1 Like

Interestingly nothing is showing up and i think that might be the thing thats throwing it off.

So comp id is what i want to post to the contacts table however the company id & company name is coming from the company table. Maybe thats where the issue is? I think i get it but not sure how to correct it :crazy_face:

Excuse the terrible example company names :joy:

The image on the left is the contacts table & the image on the right is the companies table.
47 32

what does the HTML for this dropdown look like in the browser?

It shows the company names from the companies table.

Do you think that where it’s echoing the comp list name that this is causing the integer issue when the form is submitted as looking back at it, it’s trying to post the id and the name?

<option value="<?php echo $comp_list_ID; ?>"> <?php echo $comp_list_name; ?></option>

Rudy will slap your wrist for using SELECT *, but otherwise that should work correctly.
Remove the value from the select, and it should work correctly from the form’s end.

If need be, tack $compid onto the end of one of the strings you’re inserting temporarily so you can see what value got sent to the processor.

$param_fname = $fname.$compid;

1 Like

Thanks for the suggestion. I’m away from my PC atm but will try first thing tomorrow and let you know the result.

Really appreciate the help. Thanks gents. :+1:t2:

Solved it. It’s should have been:-



Thanks again gents for your time on this one :+1:t2:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.