gpt4 book ai didi

php - 插入数据库给我 "localhost not working"

转载 作者:行者123 更新时间:2023-11-29 11:15:51 25 4
gpt4 key购买 nike

当您单击提交按钮时,我尝试通过两个输入将信息插入数据库。但是当我单击它时,它说它无法连接到本地主机(其他一切正常,所以我知道它必须是某种形式的语法问题)代码:

    <form action="prices.inc.php" method="post">
<input class="price-list-input" type="text" id="priceupdate1" name="priceupdate1" required></input>
<input class="price-list-input2" type="text" id="priceupdate2" name="priceupdate2" required></input>
<input class="price-list-button" type="submit" id="priceupdate-button" name="priceupdate-button" value="Uppdatera"></input>
</form>

php..

<?php

require_once('check_login.inc.php');
define('SECURE', true);
require_once('connection.php');


if(isset($_POST['priceupdate-button'])){

$info = trim(htmlspecialchars($_POST['priceupdate1'], $_POST['priceupdate2']));

// prepared statement
$stmt = $db->prepare('INSERT INTO prices (name, price) VALUES = (?, ?)');
$stmt->bind_param('ss', $_POST['priceupdate1'], $_POST['priceupdate2']);
$stmt->execute();
$stmt->store_result();
$stmt->bind_result($info);

}

?>

最佳答案

GOT IT WORKING.. all that was the problem was the "=" that @Fred-ii- mentioned.. – Chumppe

作为社区 wiki 发布。我不想代表这个问题,只是想结束这个问题。

As I said in comments , VALUES = (?, ?) 等号不应该出现。

手册中的示例 http://php.net/manual/en/mysqli.prepare.php

$stmt = $mysqli->prepare("INSERT INTO City (District) VALUES (?)");

关于php - 插入数据库给我 "localhost not working",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39781490/

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