我有一种发送到7个表格的表格。
如果我执行查询,那么一旦查询对数据库不起作用
而且也不要在出现问题的地方抛出错误。
我对其进行了测试,以使其一一发送并被插入。
if (isset($_POST['submit'])) {
$pdo = DB();
//step1
$business_name = $_POST['business_name'];
$business_name_eng = $_POST['business_name_eng'];
$business_name_recipe = $_POST['business_name_recipe'];
$business_type = $_POST['business_type'];
$h_p = $_POST['h_p'];
$country = $_POST['country'];
$city = $_POST['city'];
$street = $_POST['street'];
$phone = $_POST['business_phone'];
$fax = $_POST['fax'];
$email = $_POST['business_email'];
$website = $_POST['website'];
//step2
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$job = $_POST['job'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$Connection_preference = $_POST['Connection_preference'];
//step3
$line_of_business = $_POST['line_of_business'];
$local_competitors = $_POST['local_competitors'];
$national_competitors = $_POST['national_competitors'];
$main_products = $_POST['main_products'];
$profitable_products = $_POST['profitable_products'];
$secondary_products = $_POST['secondary_products'];
$more_details = $_POST['more_details'];
//step4
$facebook = $_POST['facebook'];
$instagram = $_POST['instagram'];
$googleads = isset($_POST['googleads'])?$_POST['googleads']:'לא';
$youtube = $_POST['youtube'];
$linkedin = $_POST['linkedin'];
//step5
$platform = isset($_POST['platform'])?json_encode($_POST['platform']):'';
$advertising_history = isset($_POST['advertising_history'])?$_POST['advertising_history']:'';
$advertising_external = isset($_POST['advertising_external'])?$_POST['advertising_external']:'';
$period_of_time_office = isset($_POST['period_of_time_office'])?$_POST['period_of_time_office']:'';
$price_satisfaction_office = isset($_POST['price_satisfaction_office'])?$_POST['price_satisfaction_office']:'';
$service_satisfaction_office = isset($_POST['service_satisfaction_office'])?$_POST['service_satisfaction_office']:'';
$effectiveness_advertising_office = isset($_POST['effectiveness_advertising_office'])?$_POST['effectiveness_advertising_office']:'';
$advertising_price_range = isset($_POST['advertising_price_range'])?$_POST['advertising_price_range']:'';
$effectiveness_advertising = isset($_POST['effectiveness_advertising'])?$_POST['effectiveness_advertising']:'';
$outweb_advertising = isset($_POST['outweb_advertising'])?$_POST['outweb_advertising']:'';
$outweb_location = isset($_POST['outweb_location'])?$_POST['outweb_location']:'';
$outweb_effectiveness = isset($_POST['outweb_effectiveness'])?$_POST['outweb_effectiveness']:'';
//step6
$target_audiences = isset( $_POST['target_audiences'] ) ? json_encode($_POST['target_audiences'],JSON_UNESCAPED_UNICODE) : '';
$south_advertising = $_POST['south_details'];
$center_advertising = $_POST['center_details'];
$north_advertising = $_POST['north_details'];
$abroad_advertising = $_POST['abroad_details'];
$audiences_gender = isset( $_POST['audiences_gender'] ) ? json_encode($_POST['audiences_gender'],JSON_UNESCAPED_UNICODE) : '';
//step7
$websites = $_POST['websites'];
$arr = [];
foreach($_FILES['documents']['tmp_name'] as $key => $tmp_name)
{
$file_name = $key.$_FILES['documents']['name'][$key];
$file_size =$_FILES['documents']['size'][$key];
$file_tmp =$_FILES['documents']['tmp_name'][$key];
$file_type=$_FILES['documents']['type'][$key];
$full_name = time().$file_name;
move_uploaded_file($file_tmp,"uploads/".$full_name);
$arr[] = $full_name;
}
$files = json_encode($arr,JSON_UNESCAPED_UNICODE);
//assign variable to send to DB
try {
$pdo = DB();
$stmt = $pdo->prepare("INSERT INTO client_form(
client_id,business_name,business_name_eng,business_name_recipe,business_type,h_p,country,city,street,phone,fax,email,website)
VALUES (
:client_id,:business_name,:business_name_eng,:business_name_recipe,:business_type,:h_p,:country,:city,:street,:business_phone,:fax,:business_email,:website)
INSERT INTO client_form_2(
client_id,first_name,last_name,job,phone,email,Connection_preference)
VALUES (
:client_id,:first_name,:last_name,:job,:phone,:email,:Connection_preference)
INSERT INTO client_form_3(
client_id,line_of_business,local_competitors,national_competitors,main_products,profitable_products,secondary_products,more_details)
VALUES (
:client_id,:line_of_business,:local_competitors,:national_competitors,:main_products,:profitable_products,:secondary_products,:more_details)
INSERT INTO client_form_4(
client_id,facebook,instagram,googleads,youtube,linkedin)
VALUES (
:client_id,:facebook,:instagram,:googleads,:youtube,:linkedin)
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)
INSERT INTO client_form_6(
client_id,target_audiences,south_advertising,center_advertising,north_advertising,abroad_advertising,audiences_gender)
VALUES (
:client_id,:target_audiences,:south_advertising,:center_advertising,:north_advertising,:abroad_advertising,:audiences_gender)
INSERT INTO client_form_7 (client_id, documents, websites) VALUES (:client_id, :documents, :websites)
");
//step1
$stmt->bindParam("client_id", $user_id, PDO::PARAM_INT);
$stmt->bindParam("business_name", $business_name, PDO::PARAM_STR);
$stmt->bindParam("business_name_eng", $business_name_eng, PDO::PARAM_STR);
$stmt->bindParam("business_name_recipe", $business_name_recipe, PDO::PARAM_STR);
$stmt->bindParam("business_type", $business_type, PDO::PARAM_STR);
$stmt->bindParam("h_p", $h_p, PDO::PARAM_STR);
$stmt->bindParam("country", $country, PDO::PARAM_STR);
$stmt->bindParam("city", $city, PDO::PARAM_STR);
$stmt->bindParam("street", $street, PDO::PARAM_STR);
$stmt->bindParam("business_phone", $phone, PDO::PARAM_STR);
$stmt->bindParam("fax", $fax, PDO::PARAM_STR);
$stmt->bindParam("business_email", $email, PDO::PARAM_STR);
$stmt->bindParam("website", $website, PDO::PARAM_STR);
//step2
$stmt->bindParam("client_id", $user_id, PDO::PARAM_INT);
$stmt->bindParam("first_name", $first_name, PDO::PARAM_STR);
$stmt->bindParam("last_name", $last_name, PDO::PARAM_STR);
$stmt->bindParam("job", $job, PDO::PARAM_STR);
$stmt->bindParam("phone", $phone, PDO::PARAM_STR);
$stmt->bindParam("email", $email, PDO::PARAM_STR);
$stmt->bindParam("Connection_preference", $Connection_preference, PDO::PARAM_STR);
//step3
$stmt->bindParam("client_id", $user_id, PDO::PARAM_INT);
$stmt->bindParam("line_of_business", $line_of_business, PDO::PARAM_STR);
$stmt->bindParam("local_competitors", $local_competitors, PDO::PARAM_STR);
$stmt->bindParam("national_competitors", $national_competitors, PDO::PARAM_STR);
$stmt->bindParam("main_products", $main_products, PDO::PARAM_STR);
$stmt->bindParam("profitable_products", $profitable_products, PDO::PARAM_STR);
$stmt->bindParam("secondary_products", $secondary_products, PDO::PARAM_STR);
$stmt->bindParam("more_details", $more_details, PDO::PARAM_STR);
//step4
$stmt->bindParam("client_id", $user_id, PDO::PARAM_INT);
$stmt->bindParam("facebook", $facebook, PDO::PARAM_STR);
$stmt->bindParam("instagram", $instagram, PDO::PARAM_STR);
$stmt->bindParam("googleads", $googleads, PDO::PARAM_STR);
$stmt->bindParam("youtube", $youtube, PDO::PARAM_STR);
$stmt->bindParam("linkedin", $linkedin, PDO::PARAM_STR);
//step5
$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);
//step6
$stmt->bindParam("client_id", $user_id, PDO::PARAM_INT);
$stmt->bindParam("target_audiences", $target_audiences, PDO::PARAM_STR);
$stmt->bindParam("south_advertising", $south_advertising, PDO::PARAM_STR);
$stmt->bindParam("center_advertising", $center_advertising, PDO::PARAM_STR);
$stmt->bindParam("north_advertising", $north_advertising, PDO::PARAM_STR);
$stmt->bindParam("abroad_advertising", $abroad_advertising, PDO::PARAM_STR);
$stmt->bindParam("audiences_gender", $audiences_gender, PDO::PARAM_STR);
//step7
$stmt->bindParam("client_id", $user_id, PDO::PARAM_INT);
$stmt->bindParam("documents", $files, PDO::PARAM_STR);
$stmt->bindParam("websites", $websites, PDO::PARAM_STR);
//execute
$stmt->execute();
} catch (PDOException $e) {
exit($e->getMessage());
}
}
我不确定这是否是插入多表的方法,很高兴有人向我解释问题。
编辑
解决方案
在闭合;
的每个括号之后,我误认为了VALUE()
答案 0 :(得分:0)
解决方案
在关闭;
的每个括号之后,我误认了VALUE()
的符号
结束它没有破坏代码