About the wonderful problem of account activation,

Source: Internet
Author: User
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 succeeded ', ' login.php ');} else {mysql_close (); _location (' Account activation failed ', ' Register.php ');}} else {_alert_back (' illegal operation ');}}


Reply to discussion (solution)

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 succeeded ', ' login.php ');         } else {             mysql_close ();             _location (' Account activation failed ', ' register.php ');        }    } else {         _alert_back (' illegal operation ');    }

Well, yes, I went to the table and tried it many times. I also have a print out mysql_fetch_array value

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

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) {           echo "OK";      } else {         _alert_back (' illegal operation ');}     }


What will happen?

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


Yes, that's why I'm talking about the wonderful work. I've been looking for 2 days, and I haven't found a problem.

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) {           echo "OK";      } else {         _alert_back (' illegal operation ');}     }


What will happen?



Print out OK,

One of the most recent cases is that after restarting the computer several times, after you open the project, the first registration can be activated, the latter will appear illegal operation

I'm dizzy, wondering if there's something wrong with the computer system.

You print out __file__ and __line__, you know you're in the wrong place.

Or not, let's not look for a while. Thank you, 2.

  • 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.