【发布时间】:2018-03-04 14:51:17
【问题描述】:
我正在尝试制作一个网址缩短网站。但是,当我尝试单击提交输入时遇到此错误: 致命错误:调用 C:\xampp\htdocs\index.php 中布尔值的成员函数 bind_param()。 我见过其他人遇到此问题,但从未设法解决。 提前致谢!
<?php
$db = new mysqli("localhost","root","");
if (isset($_POST['shorten'])) {
//echo "Clicked";
$result = $db->prepare("INSERT INTO links VALUES('',?,'test')");
$result->bind_param('s', $_POST['url_to_shorten']);
$result->execute();
echo "Done.";
}
?>
<!doctype html>
<html>
<head>
<title>Orix.ml - free link shortener</title>
</head>
<body>
<center>
<h1>ORIX.ML</h1>
<h2>FREE USB SHORTENING SERVICE</h2>
<form action="/" method="POST">
<input type="text" name="url_to_shorten" value="" placeholder="PASTE YOUR LINK HERE">
<input type="submit" name="shorten" value="GO">
</form>
</center>
</body>
</html>
【问题讨论】:
-
简单;你没有选择数据库。
-
如果你看到其他人有这个问题,你没有看到使用
echo $db->error;来查看错误原因的建议吗? -
当我说我很蠢的时候,我就是很蠢。谢谢@Fred-ii- 请将此作为答案发布,以便我将其选为最佳答案。
-
@Barmar 这也很重要。我会保留它作为未来的建议,谢谢!
-
@Fred-ii- 来吧,回答它。我在任何明显的重复项中都找不到这个特殊原因。