insert在mysql中不起作用

xghobddn  于 2021-06-24  发布在  Mysql
关注(0)|答案(1)|浏览(343)

我试图把数据在mysql与php,但没有显示任何错误,但价值观并没有进入数据库太多。

$query = "INSERT INTO orders (username, servicename, link, quantity, cost, date)
          VALUES('$username', '$service_name', '$link', '$quanitiy', '$cost', '$date')";
$insert=mysqli_query($db, $query);
7hiiyaii

7hiiyaii1#

我认为你的问题应该是这样的:

$conn = mysqli_connect($servername, $username, $password, $database);
// Check connection
if (!$conn) {
  die("Connection failed: " . mysqli_connect_error());
}
// create the query
$query = "INSERT INTO orders (username, servicename, link, quantity, cost, date)
          VALUES('$username', '$service_name', '$link', '$quanitiy','$cost', '$date')";
// preform the query
$insert=mysqli_query($conn, $query);
// you need to check if the insert succeeded before closing the connection
// close connection to DB
mysqli_close($conn);

相关问题