Jump to content

Prepared Statement Update Only Some Fields

Recommended Posts

HI All,

I am writing a prepared statement to update some user information.

Included in this table are the username and password fields. 

In this particular form, i dont want the user to have access to this information and have built a form that only shows what i want them to be able to change.

The bit that i am not sure about is the prepared statement that i am writing.

I am getting a boolean error suggesting that my prepare failed and i think this may be because i have not named every field in the table.

To give an idea of the table fields i have pulled this from php my_admin (this is not the sql i am running)

UPDATE `ssm_user` SET `user_id`=[value-1],`user_email`=[value-2],`user_password`=[value-3],
`user_mobile`=[value-7],`user_role`=[value-8],`user_lastlogondate`=[value-9] WHERE 1

my prepared statement is

$stmt = $conn->prepare("
			UPDATE ssm_user 
			WHERE user_id = ?

		$stmt->bind_param('sssssi', $email, $fname, $lname, $accountlevel, $mobile, $uid);
    	return $stmt->affected_rows;

Do i have to declare every field in the table or is there something that i am missing here.

Share this post

Link to post
Share on other sites
14 hours ago, Adamhumbug said:

and i think this may be because

stop guessing:



Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.