0

I am able to generate the activation_key in the following code. But I can't manage to insert it into the table. Blank value gets inserted into the table. What am I doing wrong? (using PEAR text password and other extensions)

                $activation_key = Text_Password::createFromLogin($data['email'], 'rot13');
                $sql = "INSERT INTO auth (firstname, lastname,gender,dob,mobileno,landlineno,addressline1,addressline2,addressline3,country,state,city,pincode,email,username,password,question,answer,activation_key)
                VALUES ('" . $db->escapeSimple($data['firstname']) . "','"
                                    . $db->escapeSimple($data['lastname'])."','"
                                    . $db->escapeSimple($data['gender'])."','"
                                    . $db->escapeSimple($data['dob'])."','"
                                    . $db->escapeSimple($data['mobileno'])."','"
                                    . $db->escapeSimple($data['landlineno'])."','"
                                    . $db->escapeSimple($data['address1'])."','"
                                    . $db->escapeSimple($data['address2'])."','"
                                    . $db->escapeSimple($data['address3'])."','"
                                    . $db->escapeSimple($data['country'])."','"
                                    . $db->escapeSimple($data['state'])."','"
                                    . $db->escapeSimple($data['city'])."','"
                                    . $db->escapeSimple($data['pin'])."','"
                                    . $db->escapeSimple($data['email'])."','"
                                    . $db->escapeSimple($data['username'])."','"
                                    . md5($db->escapeSimple($data['pwd']))."','"
                                    . $db->escapeSimple($data['question'])."','"
                                    . $db->escapeSimple($data['answer']). "', '"
                                    . $db->escapeSimple($data['activiation_key'])."')";
          $db->query($sql);
6
  • Have you tried printing out the value thats inside the VALUES(...) part of the query? Commented Sep 28, 2009 at 6:11
  • activation_key variable is getting generated. Because I am getting an email with that code. The problem is with the sql query. Commented Sep 28, 2009 at 6:14
  • All other columns except activation_key are correctly added. Commented Sep 28, 2009 at 6:16
  • You mispelled the variable name in the last line of the insert. Are you using any ide? Commented Sep 28, 2009 at 6:17
  • by the way, you generate the $activation_key in the first line, but insert $data['activation_key'] in the last line Commented Sep 28, 2009 at 6:20

1 Answer 1

2

$data['$activiation_key'] doesn't actually appear to hold $activation_key

plus if you really cut and paste then $activiation_key is spelt wrongly

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. 1) corrected the spelling 2) Changed the line to something like this... .$db->escapeSimple($activation_key)."')"; And it solved the problem. Is it ok to use vi or should I use something else to improve my coding time?
nothing wrong w/ vi - i used that for years and years, for php coding these days i tend to use eclipse, and notepad++ on Windows

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.