1

I am developing a user/login system, wherein I have a small php function below that updates the user values in a DB when certain condition is met (i.e. when username and password matches). However, nothing seems to happen on the login page. I am using Ubuntu and on the terminal it shows that the variable $pk_user is empty. The problem is that I want to print the values of pk_user but echo, print_r, var_dump nothing prints anything on the browser. I have CSS styling, would that be the reason? The function is:

/* updateUserField - Updates a field, specified by the field parameter,
   in the user's row of the database, given the pk_user */

public function updateUserField($userkey, $field, $value)
{
    $q = "UPDATE users SET ".$field." = '$value' WHERE pk_user = '$userkey'";

    pg_query($this->link,$q);

    if(pg_last_error($this->link)) {
        return -1;
    }

    return 1;
}

and the error message on command line is:

ERROR: invalid input syntax for integer: "" at character 82 STATEMENT: UPDATE users SET usr_userid = '9bc44a3b3b0b911f7f932f06ab7d7b5c' WHERE pk_user = ''

Of course I connect to DB with pg_connect and that part is working okay.

2
  • I can't see pk_user variable here. Query doesn't work because $userkey parameter is empty. Check function call or show us more code. Commented Jul 6, 2011 at 0:37
  • Thanks, I pointed out the error in the code. Commented Jul 7, 2011 at 5:30

1 Answer 1

1

You're not supplying an integer as the $userkey variable when you call the function. Therefore, the query is failing. Check your code where you actually call the function to determine why an integer isn't being passed.

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

Comments

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.