我试图在此处将列发布到我的数据库中作为测试,但我无法这样做。我已经使用了下面的代码,它似乎没有发布。除非我错过了PHPmyAdmin的技巧,否则我似乎无法使其正常工作。有人有机会帮忙吗?提前谢谢!
<?php
$link = mysqli_connect("XXXX", "XXXX",
"XXXX", "XXXX");
if (mysqli_connect_error ()) {
die("The connection has failed");
}
$query = "INSERT INTO `users` (`email`, `password`)
VALUES('owen@owen.com', 'hfudhf8ahdfufh')";
mysqli_query($link, $query);
$query = "SELECT * FROM users";
if($result = mysqli_query($link, $query)) {
$row = mysqli_fetch_array($result);
echo"Your Email is ".$row["email"];
echo" and your Password is ".$row["password"];
}
?>
答案 0 :(得分:0)
问题在于您只获取一行结果。除非在运行脚本之前表是空的,否则没有理由期望该行是您刚刚添加的行。
如果表格有自动增量ID字段,则可以获取该行:
$query = "SELECT * FROM users WHERE id = LAST_INSERT_ID()";