我一直在与phpMyAdmin插件争夺一段时间, 它没有给我一个错误,但它不会插入数据库。
我的代码就像这样
<html>
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="43%" id="AutoNumber1">
<tr>
<td width="100%">
<p align="left"> </td>
</tr>
<tr>
<td width="100%">
<form method="GET" name="testform" id="testform" action="logout.php">
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="69%" id="AutoNumber2" height="63">
<tr>
<td width="36%" height="22">Username</td>
<td width="64%" height="22"><input type="text" name="user" size="20"></td>
</tr>
<tr>
<td width="36%" height="22">password</td>
<td width="64%" height="22">
<input type="password" name="passwd" size="20"></td>
</tr>
<tr>
<td width="36%" height="19"> </td>
<td width="64%" height="19">
<input type="submit" value="login" name="login"></td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>
现在php也是这样的
<?php
require_once('inc/config.php');
$user = $_GET['user'];
$pass = $_GET['passwd'];
//database connection
$conn = mysqli_connect(DBHOST,DBUSER,DBPASS,DB);
//mysql anti injection
$username = mysql_real_escape_string($_GET['user']);
$password = mysql_real_escape_string($_GET['passwd']);
$sql = "INSERT INTO people (`username`, `password`) VALUES ('$username', '$password');";
mysqli_close($conn);
echo "Inserted";
?>
麻烦的是,当在本地主机上查看时,我看不到我插入到mysql数据库中的内容;有什么问题?
答案 0 :(得分:-2)
似乎问题可能出在“;”的使用上在以下行的末尾两次:
$sql = "INSERT INTO people (username
, password
) VALUES ('$username', '$password');";
尝试以下操作。
$sql = "INSERT INTO people (username
, password
) VALUES ('$username', '$password');"