Questions about the wonderful flower of account activation

Source: Internet
Author: User
About the wonderful problem of account activation,
Ask the great God my this piece of code has what problem, before good, but now appear inexplicable problem, editor is NetBeans, also reinstall.
Now the runtime can execute to the second _query function, that is, the operation of the database is successful, and then skip the Mysql_affected_rows () that segment directly executes the following else {
_alert_back (' illegal operation ');
}


if (Isset ($_get[' active ')) && $_get[' action '] = = = ' OK ') {

$_active = _mysql_string ($_get[' active ');

if (Mysql_fetch_array (_query ("Select tg_active from Tg_user WHERE tg_active= ' $_active ' LIMIT 1"), Mysql_assoc)) {

Set Tg_active to Actived
_query ("UPDATE tg_user SET tg_active= ' actived ' WHERE tg_active= ' $_active ' LIMIT 1");

if (mysql_affected_rows () = = 1) {

Mysql_close ();

_location (' Account activation successful ', ' login.php ');

} else {

Mysql_close ();

_location (' Account activation failed ', ' register.php ');
}
} else {

_alert_back (' illegal operation ');
}
}


------to solve the idea----------------------
Check your code, it should be
if (Mysql_fetch_array (_query ("Select tg_active from Tg_user WHERE tg_active= ' $_active ' LIMIT 1"), MYSQL_ASSOC))
This segment is problematic and you're sure there's an implementation to the _query stage


if (Mysql_fetch_array (_query ("Select tg_active from Tg_user WHERE tg_active= ' $_active ' LIMIT 1"), Mysql_assoc)) {

Set Tg_active to Actived
_query ("UPDATE tg_user SET tg_active= ' actived ' WHERE tg_active= ' $_active ' LIMIT 1");

if (mysql_affected_rows () = = 1) {

Mysql_close ();

_location (' Account activation successful ', ' login.php ');

} else {

Mysql_close ();

_location (' Account activation failed ', ' register.php ');
}
} else {

_alert_back (' illegal operation ');
}

------to solve the idea----------------------
In terms of the code you posted, it's impossible to say what you're saying.
Because
_query ("UPDATE tg_user SET ....")
And
_alert_back (' illegal operation ');
Sub-genus
if (Mysql_fetch_array (_query ("Select Tg_active from ...
Two branches of
cannot be executed at the same time!
Therefore, you can assume that you are not actually running this code
  • Related Article

    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.