How can you convert a string value to an integer for insertion into a MySQL database using PHP?

When inserting a string value into a MySQL database, it is important to convert it to an integer if the database column expects an integer value. This can be done using the `intval()` function in PHP, which converts a string to an integer. Simply pass the string value as a parameter to `intval()` to convert it to an integer before inserting it into the database.

$stringValue = "123";
$intValue = intval($stringValue);

// Insert $intValue into MySQL database
$query = "INSERT INTO table_name (int_column) VALUES ($intValue)";
$result = mysqli_query($connection, $query);

if($result) {
    echo "Value inserted successfully";
} else {
    echo "Error inserting value: " . mysqli_error($connection);
}