У меня есть форма с несколькими вариантами выбора, и когда я запускаю запрос на вставку, я получаю Array to string conversion error
.
Я попытался foreach , но он по-прежнему не вставляется в базу данных, и я получаю пустую страницу без ошибки или ошибки foreach.
HTML
<select multiple name="platform[]" id="platform">
<option value="" disabled>בחר כמה מהאפשרויות</option>
<option value="facebook">facebook</option>
<option value="instagram">instagram</option>
<option value="google">google</option>
<option value="youtube">youtube</option>
<option value="linkedin">linkedin</option>
</select>
PHP
if (isset($_POST['submit'])) {
$platform = $_POST['platform'];
$advertising_history = $_POST['advertising_history'];
$advertising_external = $_POST['advertising_external'];
$period_of_time_office = $_POST['period_of_time_office'];
$price_satisfaction_office = $_POST['price_satisfaction_office'];
$service_satisfaction_office = $_POST['service_satisfaction_office'];
$effectiveness_advertising_office =
$_POST['effectiveness_advertising_office'];
$advertising_price_range = $_POST['advertising_price_range'];
$effectiveness_advertising = $_POST['effectiveness_advertising'];
$outweb_advertising = $_POST['outweb_advertising'];
$outweb_location = $_POST['outweb_location'];
$outweb_effectiveness = $_POST['outweb_effectiveness'];
$valid = true;
if ($valid) {
try {
$pdo = DB();
$stmt = $pdo->prepare("
INSERT INTO client_form_5(
client_id,
advertising_history,
advertising_external,
period_of_time_office,
price_satisfaction_office,
service_satisfaction_office,
effectiveness_advertising_office,
platform,
advertising_price_range,
effectiveness_advertising,
outweb_advertising,
outweb_location,
outweb_effectiveness
)
VALUES (
:client_id,
:advertising_history,
:advertising_external,
:period_of_time_office,
:price_satisfaction_office,
:service_satisfaction_office,
:effectiveness_advertising_office,
:platform,
:advertising_price_range,
:effectiveness_advertising,
:outweb_advertising,
:outweb_location,
:outweb_effectiveness
)
");
$stmt->bindParam("client_id", $user_id, PDO::PARAM_INT);
$stmt->bindParam("advertising_history", $advertising_history, PDO::PARAM_STR);
$stmt->bindParam("advertising_external", $advertising_external, PDO::PARAM_STR);
$stmt->bindParam("period_of_time_office", $period_of_time_office, PDO::PARAM_STR);
$stmt->bindParam("price_satisfaction_office", $price_satisfaction_office, PDO::PARAM_STR);
$stmt->bindParam("service_satisfaction_office", $service_satisfaction_office, PDO::PARAM_STR);
$stmt->bindParam("effectiveness_advertising_office", $effectiveness_advertising_office, PDO::PARAM_STR);
$stmt->bindParam("platform", $platform, PDO::PARAM_STR);
$stmt->bindParam("advertising_price_range", $advertising_price_range, PDO::PARAM_STR);
$stmt->bindParam("effectiveness_advertising", $effectiveness_advertising, PDO::PARAM_STR);
$stmt->bindParam("outweb_advertising", $outweb_advertising, PDO::PARAM_STR);
$stmt->bindParam("outweb_location", $outweb_location, PDO::PARAM_STR);
$stmt->bindParam("outweb_effectiveness", $outweb_effectiveness, PDO::PARAM_STR);
$stmt->execute();
} catch (PDOException $e) {
exit($e->getMessage());
}
}
}
Я ожидаю получить в моей базе данных все варианты значений, но вместо этого я получу только слово Array.