<?php
include("dbinit.php");
$text="helow";
$eadd = $_SESSION['account'];
$result = mysqli_query($link,"SELECT * FROM account where Eadd='". $eadd ."'");
while($row = mysqli_fetch_array($result))
{
$name = $row['Name'];
}
$ctext = $_POST['ctext'];
$sql = "INSERT INTO chat (By, Content, Reported) VALUES ('$name','$ctext','No')";
mysqli_query($link,$sql);
mysqli_close($link);
$text=$name . $ctext;
echo $text;
?>
这是我的代码。在我的另一个页面中,这有效但是..当我更改“插入”中的值时,为什么我不能将它存储到数据库中?
<?php
session_start();
$link = mysqli_connect("localhost", "xxx", "xxx", "xxx");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
mysqli_select_db($link, "xxx");
header('Content-type: text/html; charset=utf-8');
?>
这是我的 dbinit 文件