gpt4 book ai didi

php - 无法插入数据

转载 作者:太空宇宙 更新时间:2023-11-03 10:59:22 26 4
gpt4 key购买 nike

我有数据库包含名为 demnads 的表表包含 11 个单元格第一个是 id 自动增加我想在 php 中使用此 sql 命令添加数据:

<?php 
$hostname_mystore = "localhost";
$database_mystore = "mystore";
$username_mystore = "root";
$password_mystore = "";
$mystore = mysql_pconnect($hostname_mystore, $username_mystore, $password_mystore) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_query("set character_set_server='utf8'");
mysql_query("set names 'utf8'");
if (mysqli_connect_errno())
{ echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql= "INSERT into demands ( itemname , case , cname , fatora , client , cdate , ctime , prices , cmobile , numbers) values('$item[$i]','$cases[$i]','$customer[$i]','$fatora[$i]','$client[$i]','$dates[$i]','$times[$i]','$price[$i]','$mobile[$i]','$numbers[$i]' )";
?>

但是没有插入数据

最佳答案

您已从 mysql 库(已弃用)切换到 mysqli:

mysqli_connect_errno()

你应该使用其中之一。

此外,嵌入的数组值需要用大括号{$item[$i]}括起来。

当然,这假设这些数组和 $i 是在别处定义的。

而且您还没有显示实际插入数据的语句。

关于php - 无法插入数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17126321/

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