Which great God can come to me to solve the problem of accessing MySQL when a user logs on
See what's wrong with the code below, why not run?
Session_Start ();
mysql_connect ("localhost", "root", "11111111")
Or Die ("Cannot connect to database, please retry");
mysql_select_db ("Manage")
Or Die ("Cannot select database, please retry");
$today =date ("y-m-d h:i:s");
$query = "SELECT ID
From Usertbl
where id= $id and secret= $secret
/* Search for and log in the user's data from the database */
";
$result =mysql_query ($query);
$numrows =mysql_num_rows ($result);
if ($numrows ==0) {
/* Verify that the user who can find the same data cannot be unregistered */
echo "Illegal user";
echo "please register First";
echo "Retry";
}
else{
$row =mysql_fetch_array ($result);
$id = $row [0];
$query = "
Update Usertbl
Set lastlogin= $today
where id= $id ";
$result =mysql_query ($query);
Setcookie ("Usercookie", "Welcome you, $id");
/* Cookies are used here to facilitate subsequent page certification.
But I didn't develop this piece. A friend who wishes to be interested.
echo "Login Successful";
echo "Come in!" ";
}
?>
------to solve the idea----------------------
Select ID from usertbl where id=
$idand secret=
$secret
Where are $id, $secret assigned values? What is the value?
In addition, single quotation marks are used to enclose
------to solve the idea----------------------
What about the error message? No error tips how to look!
$query = "SELECT ID
From Usertbl
where id= $id and secret= $secret
/* Search for and log in the user's data from the database */
";
SQL remembers strings to be quoted when writing
------to solve the idea----------------------
Write like this
where id= $id and secret= ' $secret ' ";
/* Cookies are used here to facilitate subsequent page certification.
But I didn't develop this piece. A friend who wishes to be interested.
37 lines The error is because the first line of the note is preceded by an all-width space