索引.php
<html>
<head>
<title>Josh's Online Playground</title>
</head>
<body>
<form method="POST" action="action.php">
<table>
<tr>
<td>"data for stuff"</td>
<td><input type="text" ?></td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</table>
</form>
</body>
</html>
Action .php
<?php
error_reporting(E_ALL);
ini_sit("display_errors", 1);
$mysqli = new mysqli('localhost', 'root', 'password', 'website');
$result = $mysqli->query("insert into stuff (data) values ('
.$_POST['data']
."');
echo $mysqli->error();
if($result = $mysqli->query("select data from stuff")){
echo 'There are '.$result->num_rows.' results.';
}
while ($row = $result->fetch_object()){
echo 'stuff' . $row->data;
}
?>
除了 action.php 中的前两行,我没有收到任何错误或警告消息。 相反,我在点击提交按钮后得到了一个空白页面。
我是否必须做一些不同的事情来插入数据?
最佳答案
你在 action.php 中有一个语法错误:
ini_set 不是 ini_sit 第 2 行!
关于php - mysql php问题: no error message despite error_reporting(E_ALL) line,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3044431/