Jump to content

MySQLi Prepared Statements - Passing a Variable: Question


Recommended Posts

Hey all,

I have a quick question regarding MySQLi Prepared Statements.

Say I have the following code:

$stmt = $database->stmt_init();
		$salt = '4_X4cC@p\o'eOaqf"-?gPc5'|C~UcL';

		$stmt->prepare("UPDATE table SET salt = (?) WHERE id = 1");
		$stmt->bind_param('s', $salt);
		$stmt->execute();
		$stmt->close();

 

My question is pretty simple; if I pass the value of $salt (or anything that contains a quote, double quote, or backslash) into a MySQLi Prepared Statement, will it function properly and succeed in executing the query? Or, do I need to perform mysqli_real_escape_string on the variable in order to make it so the query can read it successfully?

 

 

Thanks for any help,

Mark

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.