Jump to content

Prepared Statement Update Only Some Fields


Adamhumbug

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_firstname`=[value-4],`user_lastname`=[value-5],`user_accountlevel`=[value-6],
`user_mobile`=[value-7],`user_role`=[value-8],`user_lastlogondate`=[value-9] WHERE 1

my prepared statement is

$stmt = $conn->prepare("
			UPDATE ssm_user 
			SET 
			user_email=?,
			user_firstname=?,
			user_lastname=?,
			user_accountlevel=?,
			user_mobile=?,
			WHERE user_id = ?
			");

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

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

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