Uncaught mysqli_sql_exception: Data too long for column

I’m trying to put this in my input type “-” and example is 123-45 and I will get the error but if I use this 12345 no error showing.
currently using varchar(15) in my database to limit to 15 only ,if possible I don’t want to use longtext or text

if(empty($errors)){  
				$sql ="INSERT INTO property (full_name,tax_dec,title_lot, property_type, location,block_lot_no, imageType, imageData, status, status1, tax_payer_id) 
				VALUES (?,?,?,?,?,?,?,?,?,?,?)";
				$query = $db->prepare($sql);		
				$query->bind_param("ssssssssssi",$_SESSION['fullname'],$_POST['tax_dec'],$_POST['title_lot'],$_POST['property_type'], $_POST['location'], $_POST['block_lot_no'], $imageProperties['mime'], $imgData, $status,$status1, $_SESSION['id']);
				$query->execute(); 
				$message = "Record Added";
				header("refresh: 2; URL=property1.php");
				
			}

We have too less information to help you,

If you have varchar(15) for the column you try to put 123-45 in, then there will be no error. So the error might be somewhere else. Please show use you database Schema and do debug print of all the data you try to insert.

how to do the debug print?

You can use any logging lib for example. Or you can just add a small function like

function varDebug($var)
{
    ob_start();
    var_dump($var);
    $result = ob_get_clean();
    $fh = fopen("debug", 'a+b');
     if($fh==null)
    {
        $fh=fopen("debug.txt", "w+b");
        if($fh==null)
            return;
    }
   fwrite($fh, $result."\n\r");
    fclose($fh);
}

and then call it with your variables.

1 Like

please run this and show the results –

SHOW CREATE TABLE property