|
|

楼主 |
发表于 2023-8-20 16:13:17
|
显示全部楼层
山西省运城市
感谢提醒,我一直忽略看原先数据的格式了。我这边已经改好了
<?php
// 获取前端传递的数据
$id = $_POST['id'];
$url = "https://91haoka.cn/webapp/merchant/templet1.html?share_id=489433&id=" . $id;
$title = $_POST['title'];
$selling_point = $_POST['selling_point'];
$image1 = $_POST['image1'];
$yunying = $_POST['yunying'];
// 创建数据库连接
$servername = "localhost";
$username = "yunyuhan";
$password = "yunyuhan";
$dbname = "yunyuhan";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("数据库连接失败:" . $conn->connect_error);
}
// 对selling_point进行JSON编码,并保持非ASCII字符的原始形式
$selling_point_json = json_encode($selling_point, JSON_UNESCAPED_UNICODE);
// 构建插入数据的 SQL 语句
$sql = "INSERT INTO YX_procedure (url, name, jianjie, img, yunying) VALUES ('$url', '$title', '$selling_point_json', '$image1', '$yunying')";
if ($conn->query($sql) === TRUE) {
echo "数据插入成功!";
} else {
echo "数据插入失败:" . $conn->error;
}
// 关闭数据库连接
$conn->close();
?>
目前正常 |
|