我刚开始使用 PHP。我目前正在为我的网页编写登录脚本。当我尝试运行mysql_query(SELECT * FROM users WHERE username=$username)
时,它不起作用。我确保我使用了正确的名称,但我一直遇到查询功能的问题。这是我的代码,有人看到问题吗?
<?php
$username = $_POST['username'];
$password = $_POST['password'];
if ($username&&$password)
{
$connect = mysql_connect("host", "dbname", "password!") or die ("Couldnt connect!");
mysql_select_db("TwoogLogin") or die ('couldnt find datebase');
$query = mysql_query("SELECT * FROM users WHERE username=$username") or die ('unable to run query');
$numrows = mysql_num_rows($query);
echo $numrows;
}
else
die("Please enter a username and a password");
?>