未捕获mysqli_sql_exception:'field list'中的未知列



当我提交表格时,我会得到以下信息。

致命错误:未捕获的mysqli_sql_exception:未知列中的"字段列表"中的"internal_ref"/home/www/ruckcompliance/site/test_insert2.php:9堆栈跟踪:#0/home/www/ruckcompliance/site/test_insert2.php(9(:mysqli->prepare('INSERT INTO Cus…'(抛出#1{main}/home/www/ruckcompliance.site/test_insert2.php,第9行

它在我的本地主机上运行良好。我读过几篇文章,尝试过不同的东西,但都想不通。我的数据库中确实存在该列。

<?php
header( "refresh:100;url=customers.php" );
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
include_once 'database.php';
// Prepared statement, stage 1:
$stmt1 = $conn->prepare("INSERT INTO Customer(internal_ref) VALUES (?)");
// Prepared statement, stage 2:
$internal_ref = $_REQUEST['internal_ref'];

$stmt1->bind_param("s", $internal_ref);

$stmt1->execute();
echo "<strong>Record saved....</strong>"; echo 'redirecting to dashboard.';
// Close connection
mysqli_close($conn);
?>

database.php

<?php
$servername='localhost';
$username='******';
$password='******';
$dbname = "ruck";
$conn=mysqli_connect($servername,$username,$password,"$dbname");
if(!$conn){
die('Could not Connect My Sql:' .mysql_error());
}
?>

检查您是否在数据库或php中出错。例如,我在列名中的名字是";pas单词";而不是";pass单词";。

我的数据库表有问题。我最初是用保存在excel文档中的SQL创建表格的。我在phpMyAdmin中从头开始重新创建我的表,它现在可以工作了。还在努力找出问题所在。表的名称在正确的地方。

最新更新