I have a table with various VARCHAR fields in MySQL. I would like to insert some user data from a form via PHP. Obviously if I know the field lengths in PHP, I can limit the
You can use column metadata to check string length. (PHP Manual on PDOStatement->getColumnMeta)
Get metadata for whole table this way
$query = $conn->query("SELECT * FROM places");
$numcols = $query->columnCount();
$tablemeta = array();
for ($i = 0; $i < $numcols; $i++) {
$colmeta = $query->getColumnMeta($i);
$tablemeta[$colmeta['name']] = $colmeta;
}