【发布时间】:2015-07-17 01:34:58
【问题描述】:
我有一个系统,由运行在 2008 R2 上的 Web 表单和 Mysql 服务器组成。我已经安装了 MySql 和 pma 没有任何问题,并验证它们正在工作并且可以访问。我在开发机器上创建了这个系统,一切运行良好。现在我将文件移动到实时服务器,我收到以下错误消息“localhost via TCP/IP string(61)“Incorrect decimal value: '' for column 'desiccant_1' at row 1”
有没有人可以解决这个错误?感谢您的时间。我已包含所有文件,如果需要更多信息,请告诉我。
数据库名称是 comms。
网络表单:
<body>
<p>Complete form and submit:</p>
<form class="form" method="post" action="ealwReport.php">
<label for="desiccant_1">desiccant_1</label>
<input type="number"step="0.01" name="desiccant_1" min="0" max="16.5" /><br />
<label for="desiccant_2">desiccant_2</label>
<input type="number"step="0.01" name="desiccant_2" min="0" max="16.5" /><br />
<label for="desiccant_3">desiccant_3</label>
<input type="number"step="0.01" name="desiccant_3" min="0" max="16.5" /><br />
<label for="desiccant_4">desiccant_4</label>
<input type="number"step="0.01" name="desiccant_4" min="0" max="16.5" /><br />
<label for="desiccant_5">desiccant_5</label>
<input type="number"step="0.01" name="desiccant_5" min="0" max="16.5" /><br />
<label for="desiccant_6">desiccant_6</label>
<input type="number"step="0.01" name="desiccant_6" min="0" max="16.5" /><br />
<br />
<label for="laser_1">laser_1</label>
<input type="number"step="0.01" name="laser_1" min="0" max="16.5" /><br />
<label for="laser_2">laser_2</label>
<input type="number"step="0.01" name="laser_2" min="0" max="16.5" /><br />
<label for="laser_3">laser_3</label>
<input type="number"step="0.01" name="laser_3" min="0" max="16.5" /><br />
<label for="laser_4">laser_4</label>
<input type="number"step="0.01" name="laser_4" min="0" max="16.5" /><br />
<label for="laser_5">laser_5</label>
<input type="number"step="0.01" name="laser_5" min="0" max="16.5" /><br />
<label for="laser_6">laser_6</label>
<input type="number"step="0.01" name="laser_6" min="0" max="16.5" /><br />
<br />
<label for="table_top_1">table_top_1</label>
<input type="number"step="0.01" name="table_top_1" min="0" max="16.5" /><br />
<label for="table_top_2">table_top_2</label>
<input type="number"step="0.01" name="table_top_2" min="0" max="16.5" /><br />
<br />
<label for="RMI">RMI</label>
<input type="number"step="0.01" name="RMI" min="0" max="16.5" /><br />
<label for="Miscellaneous">Miscellaneous</label>
<input type="number"step="0.01" name="Miscellaneous" /><br />
<br />
<label for="User">User</label>
<input type="text" name="User" /><br />
<label for="Date">Date</label>
<input input type="text" name="Date" value="<?php echo date('F j, Y, G:i');?>" readonly/><br />
<label for="comments">Comments?</label>
<textarea class="text" name="comments"></textarea><br />
<br />
<input type="submit" class="submit" value="submit" name="submit" />
</form>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = Date();
</script>
</body>
Web 表单发布到以下脚本“ealwReport.php”:
<?php
$desiccant_1 = $_POST['desiccant_1'];
$desiccant_2 = $_POST['desiccant_2'];
$desiccant_3 = $_POST['desiccant_3'];
$desiccant_4 = $_POST['desiccant_4'];
$desiccant_5 = $_POST['desiccant_5'];
$desiccant_6 = $_POST['desiccant_6'];
$laser_1 = $_POST['laser_1'];
$laser_2 = $_POST['laser_2'];
$laser_3 = $_POST['laser_3'];
$laser_4 = $_POST['laser_4'];
$laser_5 = $_POST['laser_5'];
$laser_6 = $_POST['laser_6'];
$table_top_1 = $_POST['table_top_1'];
$table_top_2 = $_POST['table_top_2'];
$RMI = $_POST['RMI'];
$Miscellaneous = $_POST['Miscellaneous'];
$User = $_POST['User'];
$Date = $_POST['Date'];
$comments = $_POST['comments'];
$dbc = mysqli_connect('localhost', 'root', 'xxxxx', 'comms')
or die('Error connecting to MySQL server.');
echo mysqli_get_host_info($dbc) . "\n";
将数据插入数据库:
$query = "INSERT INTO ealw (desiccant_1, desiccant_2, desiccant_3, desiccant_4, " .
"desiccant_5, desiccant_6, laser_1, laser_2, laser_3, laser_4, laser_5, " .
"laser_6, table_top_1, table_top_2, RMI, Miscellaneous, User, Date, comments) " .
"VALUES ('$desiccant_1', '$desiccant_2', '$desiccant_3', '$desiccant_4', '$desiccant_5', " .
"'$desiccant_6', '$laser_1', '$laser_2', '$laser_3', '$laser_4','$laser_5', " .
"'$laser_6', '$table_top_1','$table_top_2', '$RMI', " .
"'$Miscellaneous', '$User', '$Date', '$comments')";
$result = mysqli_query($dbc, $query)
or die (var_dump(mysqli_error($dbc)));
ERROR RECEIVED = localhost via TCP/IP string(61)“十进制值不正确:'' for column 'desiccant_1' at row 1”
从数据库返回最新记录:
$sql2 = "SELECT desiccant_1, desiccant_2, desiccant_3, desiccant_4, desiccant_5
, desiccant_6, laser_1, laser_2, laser_3, laser_4, laser_5, laser_6
, table_top_1, table_top_2, RMI, Miscellaneous FROM ealw ORDER BY id DESC LIMIT 1";
$result2 = mysqli_query($dbc, $sql2);
?>
表结构:
CREATE TABLE IF NOT EXISTS `ealw` (
`id` int(11) NOT NULL,
`desiccant_1` decimal(4,2) NOT NULL DEFAULT '0.00',
`desiccant_2` decimal(4,2) NOT NULL DEFAULT '0.00',
`desiccant_3` decimal(4,2) NOT NULL DEFAULT '0.00',
`desiccant_4` decimal(4,2) NOT NULL DEFAULT '0.00',
`desiccant_5` decimal(4,2) NOT NULL DEFAULT '0.00',
`desiccant_6` decimal(4,2) NOT NULL DEFAULT '0.00',
`laser_1` decimal(4,2) NOT NULL DEFAULT '0.00',
`laser_2` decimal(4,2) NOT NULL DEFAULT '0.00',
`laser_3` decimal(4,2) NOT NULL DEFAULT '0.00',
`laser_4` decimal(4,2) NOT NULL DEFAULT '0.00',
`laser_5` decimal(4,2) NOT NULL DEFAULT '0.00',
`laser_6` decimal(4,2) NOT NULL DEFAULT '0.00',
`table_top_1` decimal(4,2) NOT NULL DEFAULT '0.00',
`table_top_2` decimal(4,2) NOT NULL DEFAULT '0.00',
`RMI` decimal(4,2) NOT NULL DEFAULT '0.00',
`Miscellaneous` decimal(4,2) NOT NULL DEFAULT '0.00',
`User` text NOT NULL,
`Date` text NOT NULL,
`comments` text
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=latin1;
【问题讨论】:
-
在您的插入查询中,列部分中的一些点为什么?
-
嗨,阿南特。这些是用于 PHP 连接的,对我来说更容易阅读,没有其他原因。
-
看看这个小提琴:runnable.com/me/VUpmM4Q54tQiDowA
-
嗨罗伯特,我无法访问该页面,我收到“抱歉,您尝试查看的页面不存在。”
-
您可以转储 $_POST 以及 SQL 错误吗?另外,您的实时数据库是否有可能处于“严格”模式,而不是您的开发数据库?
标签: php mysqli windows-server-2008-r2