Which great God can come to my little brother? Issues related to accessing MySQL when a user logs on

Source: Internet
Author: User
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
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.