gpt4 book ai didi

php - 当字符串中存在唯一数据时,如何使用php插入数据

转载 作者:行者123 更新时间:2023-11-29 22:08:14 24 4
gpt4 key购买 nike

我试图在 wordpress 表中手动插入一些数据,但每当我运行查询时,它都会给我这个错误:--

PHP Parse error:  syntax error, unexpected T_LNUMBER in /home/yogi/public_html/shontp/wp-content/themes/bridge-child/jut-login.php on line 19

这是插入查询的代码:--

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT INTO `ssdcu_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '15', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}')";

if ($conn->multi_query($sql) === TRUE) {
echo "New records created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}

$conn->close();

最佳答案

替换

$sql = "INSERT INTO `ssdcu_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '15', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}')";

$sql = "INSERT INTO `ssdcu_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) 
VALUES (NULL, '15', 'wp_capabilities', 'a:1:{s:13:\"administrator\";s:1:\"1\";}')";

关于php - 当字符串中存在唯一数据时,如何使用php插入数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31955768/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com