I understand mysql_
has been deprecated, but I'm just using it as a tool to learn from a book.
I'm trying to learn about placeholders and I got the following error when I clicked on "add record":
INSERT failed: EXECUTE statement USING @first,@last,@email,@user
Unknown prepared statement handler (statement) given to EXECUTE
using the following code:
if (isset($_POST['first']) && isset($_POST['last']) && isset($_POST['user_name']) && isset($_POST['email']))
{
$first = get_post('first');
$last = get_post('last');
$email = get_post('email');
$user_name = get_post('user_name');
// begin placeholde code
$query = 'PREPARE statement FROM "INSERT INTO user_master VALUES(?,?,?,?)"';
mysql_query($query);
$query = 'SET @first = "$first",' . 'SET @last = "$last",' . 'SET @email = "$email",' . 'SET @user_name = "$user_name",';
mysql_query($query);
$query = 'EXECUTE statement USING @first,@last,@email,@user';
mysql_query;
// end placeholder code
if(!mysql_query($query, $db_server)) echo "INSERT failed: $query <br />" . mysql_error() . "<br /><br />";
}
echo <<<END
<form action = "willingLog.html" method="post"><fieldset><legend>Sign Up:</legend> <pre>
First <input type="text" name="first" />
Last <input type="text" name="last" />
Email <input type="text" name="email" />
Username <input type="text" name="user_name" />
<input type="submit" value="AD RECORD" />
</pre></fieldset></form>
END;
// also from placeholder code
$query = 'DEALLOCATE PREPARE statement';
mysql_query($query);
// end placeholder code