PHP MySQL
Here is the Code section:
$username =$_post["name"];
$password =$_post["Password"];
if ($username && $password)
{
if (Strpos ($username, "")!==false) echo "User name is illegal";
Else
{
$con =mysql_connect ("localhost", "root", "1");
mysql_select_db ("Manage", $con);
$sql = "
Select password
From user
where Username= ' $username '
";
$query =mysql_query ($sql);
$row =mysql_num_rows ($query);
if ($row!=0) echo ' login succeeded ';
Else
Echo ' Login failed ';
}
}
?>
Reply to discussion (solution)
$query = mysql_query ($sql) or Die (Mysql_error ());
$query = mysql_query ($sql) or Die (Mysql_error ());
What does that mean?
You'll find out if you try.
You'll find out if you try.
Moderator can give a Q not, good advice.
Landlord code in the native Apache run, there is no problem. Landlord's problem should be connected to the database failure, which is likely
mysql_select_db ("Manage", $con);
There is an error in this line of code. The moderator's practice is to provide error messages.
It is recommended that $res=mysql_query ($sql, $con) Add "or Die (' Get failed '). Mysql_error ());"
The landlord's PHP operation MySQL practice a bit irregular, it is recommended that the landlord spend a little time to see the Preach Wisdom Podcast PHP video tutorial 89th. It's great for you to use your code for the first time and find a mistake.
$query =mysql_query ($sql); There is no correct return of a resource
As for why we can only analyze the moderator's practice is to help you analyze the cause of the problem
Put you $query =mysql_query ($sql); Replace it with the one that the moderator gave you run it again try
Or you can use the database management software such as navicat the SQL statements in the inside to see if the results can be correctly found.