Php Folks,
Look at this procedural style php prepared statement.
I want to know why this query fails:
[code]
“UPDATE users SET first_name = ?, middle_name = ?, surname = ?, gender = ?, marital_status = ?, working_status = ? WHERE id = ?”;
Where is the syntax error ? Do you see any ? Cos I don’t.
**Prepare failed:
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘”UPDATE users SET first_name = ?, middle_name = ?, surname = ?, gender = ?, mari’ at line 1
“UPDATE users SET first_name = ?, middle_name = ?, surname = ?, gender = ?, marital_status = ?, working_status = ? WHERE id = ?”;
Here is the complicated context:
[code]
//Connect to Database. (DB_SERVER, BD_USERNAME, DB_PASSWORD, DB_NAME).
$conn = mysqli_connect(“localhost”,”root”,””,”powerpage”);
$conn->set_charset(‘utf8mb4’); //Always set Charset.
if($conn === false)
{
die(“ERROR: Connection Error!. ” . mysqli_connect_error());
}
//Prepare an UPDATE Statement.
$sql_query = “”UPDATE users SET “;//Half built the query. Now got to grab the Column Names (which need querying) that match the form Item Names.
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(” “,”_”,”$value”); //Replaced Spaces to Underscores.
$value_2 = strtolower(“$value_1”); //Replaced Upper Case to Lower Case.
if(isset($_POST[“$value_2”]) && !empty($_POST[“$value_2”]))
{
$sql_query = “$sql_query” . “$value_2 = ?, “;
}
}
$sql_query = “$sql_query” . “WHERE id = ?”;”;
//Now below, need to fix the last part of the Mysql Tbl Query as query has been generated something like this with a comma after the final column name’s placeholder. Eg. $sql_query = “UPDATE users SET first_name = ?, surname = ?, WHERE id = ?”;
$value_3 = $sql_query;
$value_4 = str_replace(“= ?, WHERE”,”= ? WHERE”,”$value_3″);//Replaced the Comma after the final column name’s placeholder.
$sql_query = $value_4;
echo “$sql_query<br>”;
$stmt = mysqli_prepare($conn,$sql_query);
if($stmt == false)
{
// just for debugging for now:
die(“<pre>Prepare failed:n”.mysqli_error($conn).”n$sql_query</pre>”);
}
Remember, when I echo the $sql_query, I see this:
**“UPDATE users SET first_name = ?, middle_name = ?, surname = ?, gender = ?, marital_status = ?, working_status = ? WHERE id = ?”;
Now where is the supposed syntax error there ?
<i>
</i>$sql_query = ""UPDATE users SET ";
^^
<i>
</i>"UPDATE users SET first_name = ?, middle_name = ?, surname = ?, gender = ?, marital_status = ?, working_status = ? WHERE id = ?";
<i>
</i>$sql_query = ""UPDATE users SET ";
<i>
</i>$sql_query = "$sql_query" . "WHERE id = ?";";
<i>
</i>//Prepare an UPDATE Statement.
$sql_query = ""UPDATE users SET ";//Half built the query. Now got to grab the Column Names (which need querying) that match the form Item Names.
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i> if(isset($_POST["$value_2"]) && !empty($_POST["$value_2"]))
<i> </i> {
<i> </i> $sql_query = "$sql_query" . "$value_2 = ?, ";
<i> </i> }
<i> </i> }
<i> </i> $sql_query = "$sql_query" . "WHERE id = ?";";
<i> </i> //Now below, need to fix the last part of the Mysql Tbl Query as query has been generated something like this with a comma after the final column name's placeholder. Eg. $sql_query = "UPDATE users SET first_name = ?, surname = ?, WHERE id = ?";
<i> </i> $value_3 = $sql_query;
<i> </i> $value_4 = str_replace("= ?, WHERE","= ? WHERE","$value_3");//Replaced the Comma after the final column name's placeholder.
<i> </i> $sql_query = $value_4;
<i> </i> echo "$sql_query<br>";
<i>
</i>//Prepare an UPDATE Statement.
$sql_query = "UPDATE users SET ";//Half built the query. Now got to grab the Column Names (which need querying) that match the form Item Names.
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>if(isset($_POST["$value_2"]) && !empty($_POST["$value_2"]))
<i> </i>{
<i> </i> $sql_query = "$sql_query" . "$value_2 = ?, ";
<i> </i>}
}
$sql_query = "$sql_query" . "WHERE id = ?";
<i>
</i>//Prepare an UPDATE Statement.
$sql_query = 'UPDATE users SET ';//Half built the query. Now got to grab the Column Names (which need querying) that match the form Item Names.
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>if(isset($_POST["$value_2"]) && !empty($_POST["$value_2"]))
<i> </i>{
<i> </i> $sql_query = "$sql_query" . "$value_2 = ?, ";
<i> </i>}
}
$sql_query = $sql_query . 'WHERE id = ?;';
<i>
</i>$sql_query = $sql_query . 'WHERE id = ?;';
<i>
</i>//Prepare an UPDATE Statement.
$sql_query = 'UPDATE users SET ';//Half built the query. Now got to grab the Column Names (which need querying) that match the form Item Names.
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>if(isset($_POST["$value_2"]) && !empty($_POST["$value_2"]))
<i> </i>{
<i> </i> $sql_query = $sql_query . "$value_2 = ?, ";
<i> </i>}
}
$sql_query = $sql_query . 'WHERE id = ?;';
//Now below, need to fix the last part of the Mysql Tbl Query as query has been generated something like this with a comma after the final column name's placeholder. Eg. $sql_query = "UPDATE users SET first_name = ?, surname = ?, WHERE id = ?";
$value_3 = $sql_query;
$value_4 = str_replace("= ?, WHERE","= ? WHERE","$value_3");//Replaced the Comma after the final column name's placeholder.
$sql_query = $value_4;
echo "$sql_query<br>"; echo "Line:277<br>";
<i>
</i>//Prepare an UPDATE Statement.
$sql_query = 'UPDATE users SET ';//Half built the query. Now got to grab the Column Names (which need querying) that match the form Item Names.
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>if(isset($_POST["$value_2"]) && !empty($_POST["$value_2"]))
<i> </i>{
<i> </i> $sql_query = $sql_query . "$value_2 = ?, ";
<i> </i>}
}
$sql_query = $sql_query . 'WHERE id = ?;';
//Now below, need to fix the last part of the Mysql Tbl Query as query has been generated something like this with a comma after the final column name's placeholder. Eg. $sql_query = "UPDATE users SET first_name = ?, surname = ?, WHERE id = ?";
$value_3 = $sql_query;
$value_4 = str_replace("= ?, WHERE","= ? WHERE","$value_3");//Replaced the Comma after the final column name's placeholder.
$sql_query = $value_4;
echo "$sql_query<br>"; echo "Line:277<br>";
$stmt = mysqli_prepare($conn,$sql_query);
if($stmt == False)
{
//Close Connection.
mysqli_close($conn);
echo "Line 300<br>";//DELETE THIS
die("<pre>Mysqli Prepare Failed!n".mysqli_error($conn)."n$sql_query</pre>");
}
else //TROUBLE STARTING FROM THIS POINT ONWARDS!
{
//Generate the mysqli_stmt_bind_param() in parts to generate the variables matching the 'Column Names'.
$_SESSION["id"] = 0; //DELETE THIS LINE
$mysqli_stmt_bind_param_part_1 = 'mysqli_stmt_bind_param($';
$mysqli_stmt_bind_param_part_2 = 'stmt,'ssssssi',';
<i> </i>foreach($form_questions_labels AS $form_question_label)
<i> </i>{
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i> if($form_question_label == $form_questions_labels[0])
<i> </i> {
<i> </i> $mysqli_stmt_bind_param_part_3 = '$' . "$value_2,";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> $mysqli_stmt_bind_param_part_3 = "$mysqli_stmt_bind_param_part_3" . '$' . "$value_2,";
<i> </i> }
<i> </i> }
$mysqli_stmt_bind_param_part_4 = '$_SESSION["id"])';
$mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_1" . "$mysqli_stmt_bind_param_part_2" . "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4"; //Now Bind Param looks like this: mysqli_stmt_bind_param($stmt,'ssssssss',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,13);
//Attempt to Execute the Prepared Statement.
if(!mysqli_stmt_execute($stmt))
{
//Close Connection.
mysqli_close($conn);
echo "Line 322<br>";//DELETE THIS
die("<pre>Statement Execution Failed!n".mysqli_error($conn)."n$mysqli_stmt_bind_param</pre>");
}
mysqli_stmt_execute()
mysqli_stmt_error($stmt)
mysqli_error($conn)
$sql
<i>
</i>$stmt = mysqli_prepare($conn,$sql_query);
if($stmt == False)
{
//Close Connection.
mysqli_close($conn);
echo "Line 293<br>";//DELETE THIS
die("<pre>Mysqli Prepare Failed!n".mysqli_error($conn)."n$sql_query</pre>");
}
<i>
</i>mysqli_stmt_error($stmt)
<i>
</i>mysqli_prepare_error($stmt)
mysqli_bind_error($stmt)
mysqli_stmt_error($stmt)
<i>
</i>if(!mysqli_stmt_execute($stmt))
{
//Close Connection.
mysqli_close($conn);
echo "Line 322<br>";//DELETE THIS
die("<pre>Statement Execution Failed!n".mysqli_stmt_error($stmt)."n$mysqli_stmt_bind_param</pre>");
}
<i>
</i>$stmt = mysqli_prepare($conn,$sql_query);
if($stmt == False)
{
//Close Connection.
mysqli_close($conn);
echo "Line 293<br>";//DELETE THIS
die("<pre>Mysqli Prepare Failed!n".mysqli_stmt_error($stmt)."n$sql_query</pre>");
<i>
</i><?php
error_reporting(E_ALL);
?>
<!DOCTYPE HTML">
<html>
<head>
<meta name="viewport" content="width-device=width, initial-scale=1">
</head>
<body>
<?php
if(session_id() == '')
{
echo "Line 16 <br>";
echo "Session Status:"; echo session_status(); echo "<br>";
session_start();
$_SESSION['session_step'] = 'start';
echo "Line 21 <br>";
echo "Session Status:"; echo session_status(); echo "<br>";
echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
}
if($_SESSION['session_step'] != 'end');
{
echo "Line 28 <br>";
echo "Session Status:"; echo session_status(); echo "<br>";
echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
<i> </i>if(isset($_GET['session_type']) && !empty($_GET['session_type']))
<i> </i>{
<i> </i> $_SESSION['session_type'] = $_GET['session_type'];
<i> </i> //echo session_id();
<i> </i> if(!function_exists($_SESSION['session_type']))
<i> </i> {
<i> </i> die("Invalid Session");
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> echo "Line 42<br>";//THIS LINE SHOULD NOT ECHO AFTER CLICKING THE SUBMIT BUTTON SINCE 1). IT IS BEFORE THE SUBMIT BUTTON IN THE SCRIPT FLOW. AND 2). AFTER CLICKING THE SUBMIT BUTTON $_SESSION['session_step'] = 'end';! THIS LINE SHOULD ONLY ECHO IF $_SESSION['session_step'] = 'start'; WHY IS THIS LINE ECHOING AFTER CLICKING THE SUBMIT BUTTON ?
<i> </i> echo "Session Status:"; echo session_status(); echo "<br>";
<i> </i> echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
<i> </i> $_SESSION['session_type']();
<i> </i> }
<i> </i>}
<i> </i>else
<i> </i>{
<i> </i> die("Invalid Session");
<i> </i>}
<i> </i>function submit_personal_details()
<i> </i>{
<i> </i> $session_type = $_SESSION['session_type'];
<i> </i>
<i> </i> $form_questions_labels[]='First Name';
<i> </i> $form_questions_labels[]='Middle Name';
<i> </i> $form_questions_labels[]='Surname';
<i> </i> $form_questions_labels[]='Gender';
<i> </i> //$form_questions_labels[]='Age_Range';
<i> </i> $form_questions_labels[]='Marital Status';
<i> </i> $form_questions_labels[]='Working Status';
<i> </i>
<i> </i> $form_questions_labels_required[]='First Name';
<i> </i> $form_questions_labels_required[]='Surname';
<i> </i> $form_questions_labels_required[]='Gender';
<i> </i> //$form_questions_labels_required[]='Age_Range';
<i> </i> $form_questions_labels_required[]='Marital Status';
<i> </i> $form_questions_labels_required[]='Working Status';
<i> </i>
<i> </i> $text_fields_labels = array('First Name','Middle Name','Surname');
<i> </i> $radio_buttons_labels = array('Gender');
<i> </i> $drop_downs_labels = array('Marital Status','Working Status');
<i> </i> /*
<i> </i> $i=1;
<i> </i> $options_radio_button_[$i] = array('Male','Female','Male To Female','Female To Male');
<i> </i> $i=2;
<i> </i> $options_radio_button_[$i] = array('Yes','No');
<i> </i> */
<i> </i> /*
<i> </i> $i=1;
<i> </i> $options_drop_down_[$i] = array('Single','Married','Divorced','Widow');
<i> </i> $i=2;
<i> </i> $options_drop_down_[$i] = array('Selfemployed','Employed','Unemployed');
<i> </i> */
<i> </i> //Gender Options
<i> </i> $i=1;
<i> </i> $options_radio_button_[$i][]='Male';
<i> </i> $options_radio_button_[$i][]='Female';
<i> </i> $options_radio_button_[$i][]='Male To Female';
<i> </i> $options_radio_button_[$i][]='Female To Male';
<i> </i> $total_options_radio_button_[$i] = count($options_radio_button_[$i]);//4
<i> </i> /*
<i> </i> //Tos Options
<i> </i> $i=2;
<i> </i> $options_radio_button_[$i][]='Yes';
<i> </i> $options_radio_button_[$i][]='No';
<i> </i> $total_options_radio_button_[$i] = count($options_radio_button_[$i]);//2
<i> </i> */
<i> </i> //Marital Status Options
<i> </i> $i=1;
<i> </i> $options_drop_down_[$i][]='Single';
<i> </i> $options_drop_down_[$i][]='Married';
<i> </i> $options_drop_down_[$i][]='Divorced';
<i> </i> $options_drop_down_[$i][]='Widow';
<i> </i> $total_options_drop_down_[$i] = count($options_drop_down_[$i]);//4
<i> </i> //Working Status Options
<i> </i> $i=2;
<i> </i> $options_drop_down_[$i][]='Selfemployed';
<i> </i> $options_drop_down_[$i][]='Employed';
<i> </i> $options_drop_down_[$i][]='Unemployed';
<i> </i> $total_options_drop_down_[$i] = count($options_drop_down_[$i]);//3
<i> </i> $total_form_questions_labels = 8;
<i> </i> $total_form_questions_labels_required = 7;
<i> </i> $total_text_fields_labels = 4;
<i> </i> $total_radio_buttons_labels = count($radio_buttons_labels);//2
<i> </i> $total_drop_downs_labels = count($drop_downs_labels);//2
<i> </i> ?>
<i> </i> <form action="<?php echo $_SERVER['PHP_SELF'];?>?session_type=<?php echo $_SESSION['session_type'];?>" method="post" enctype="plain/text">
<i> </i> <?php
<i> </i> foreach($form_questions_labels as $form_question_label) //Loop through the whole 'Form Questions' array.
<i> </i> {
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>
<i> </i> //Check if current 'Form Item' is a 'Text Field' or not.
<i> </i> if(in_array("$form_question_label",$text_fields_labels)) //Current 'Form Item' proved to be a 'Text Field'.
<i> </i> {
<i> </i> //Check if current 'Form Item' (Text Field) is a 'required' one or not.
<i> </i> if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Text Field) proved to be a 'required' one.
<i> </i> {
<i> </i> //Added '*' (asterisk) to indicate the 'Text Field' is a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label *:</label>
<i> </i> <input type="text" name="$value_2" placeholder="$form_question_label" value = "">";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> //Added no '*' (asterisk) to indicate the 'Text Field' is NOT a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label:</label>
<i> </i> <input type="text" name="$value_2" placeholder="$form_question_label">";
<i> </i> }
<i> </i> echo "<br>";
<i> </i> }
<i> </i> //Check if current 'Form Item' is a 'Radio Button' or not.
<i> </i> if(in_array("$form_question_label",$radio_buttons_labels)) //Current 'Form Item' proved to be a 'Radio Button'.
<i> </i> {
<i> </i> //Check if current 'Form Item' (Radio Button) is a 'required' one or not.
<i> </i> if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Radio Button) proved to be a 'required' one.
<i> </i> {
<i> </i> //Added '*' (asterisk) to indicate the 'Radio Button' is a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label *:</label>";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> //Added no '*' (asterisk) to indicate the 'Radio Button' is NOT a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label:</label>";
<i> </i> }
<i> </i> $i = 0;
<i> </i> foreach($radio_buttons_labels as $radio_button_label) //$radio_buttons_labels = ('Gender','Tos');
<i> </i> {
<i> </i> if($form_question_label == $radio_button_label) //eg. 'Gender'.
<i> </i> {
<i> </i> $i++;
<i> </i> foreach($options_radio_button_[$i] as $option_radio_button_[$i])
<i> </i> {
<i> </i> echo "<input type="radio" id="$option_radio_button_[$i]" name="$value_2" value="$option_radio_button_[$i]">
<i> </i> <label_for="$option_radio_button_[$i]">$option_radio_button_[$i]</label>";
<i> </i> }
<i> </i> echo "<br>";
<i> </i> }
<i> </i> $i++;
<i> </i> }
<i> </i> }
<i> </i> //Check if current 'Form Item' is a 'Drop Down' or not.
<i> </i> if(in_array("$form_question_label",$drop_downs_labels)) //Current 'Form Item' proved to be a 'Drop Down'.
<i> </i> {
<i> </i> //Check if current 'Form Item' (Drop Down) is a 'required' one or not.
<i> </i> if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Drop Down) proved to be a 'required' one.
<i> </i> {
<i> </i> //Added '*' (asterisk) to indicate the 'Drop Down' is a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label *:</label>";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> //Added no '*' (asterisk) to indicate the 'Drop Down' is NOT a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label:</label>";
<i> </i> }
<i> </i> $i = 0;
<i> </i> foreach($drop_downs_labels as $drop_down_label)//$drop_downs_labels = ('Marital Status','Working Status');
<i> </i> {
<i> </i> if($form_question_label == $drop_down_label)
<i> </i> {
<i> </i> $i++;
<i> </i> echo "<select name="$value_2">";
<i> </i> echo "<option value="$option_drop_down_[$i]">$option_drop_down_[$i]</option>";
<i> </i> foreach($options_drop_down_[$i] as $option_drop_down_[$i])
<i> </i> {
<i> </i> echo "<option value="$option_drop_down_[$i]">$option_drop_down_[$i]</option>";
<i> </i> }
<i> </i> echo "</select>";
<i> </i> echo "<br>";
<i> </i> }
<i> </i> $i++;
<i> </i> }
<i> </i> }
<i> </i> }
<i> </i> ?>
<i> </i> <input type="submit" name="submit_personal_details" value="Submit">
<i> </i> <?php
<i> </i> //$current_function = __FUNCTION__;
<i> </i> //echo $current_function;
<i> </i>
<i> </i> if($_SERVER['REQUEST_METHOD'] === 'POST')
<i> </i> {echo "Line 217<br>";
<i> </i> if(isset($_POST['submit_personal_details']) && $_SESSION['session_step'] != 'end')
<i> </i> {
<i> </i> $_SESSION['session_step'] = 'end';
<i> </i> echo "Line 223<br>";
<i> </i> echo "Session Status:"; echo session_status(); echo "<br>";
<i> </i> echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
<i> </i> foreach($form_questions_labels_required AS $form_question_label_required)
<i> </i> {
<i> </i> $value = $form_question_label_required;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>
<i> </i> if(!isset($_POST["$value_2"]) || trim ($_POST["$value_2"]) === '')//Do not use 'empty($_POST["$value_2"]))' here as a '0' value is considered 'empty' value.
<i> </i> {
<i> </i> echo "Fill-in All required Form Fields that! Fields with asterisks * are required to be filled-in!<br>";
<i> </i> //die("Fill-in All required Form Fields that! Fields with asterisks * are required to be filled-in!");
<i> </i> }
<i> </i> /*
<i> </i> else
<i> </i> {
<i> </i> echo "$value_2<br>"; echo "Line 227!<br>";
<i> </i> }
<i> </i> */
<i> </i> }
<i> </i> echo "Line 242<br>";
<i> </i> echo "Session Status:"; echo session_status(); echo "<br>";
<i> </i> echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
<i> </i> session_destroy();
<i> </i> echo "Line 246<br>";
<i> </i> echo "Session Status:"; echo session_status(); echo "<br>";
<i> </i> echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
<i> </i>
<i> </i> //Connect to Database. (DB_SERVER, BD_USERNAME, DB_PASSWORD, DB_NAME).
<i> </i> $conn = mysqli_connect("localhost","root","","powerpage");
<i> </i> $conn->set_charset('utf8mb4'); //Always set Charset.
<i> </i>
<i> </i> if($conn === false)
<i> </i> {
<i> </i> die("ERROR: Connection Error!. " . mysqli_connect_error());
<i> </i> }
<i> </i>
<i> </i> //Prepare an UPDATE Statement.
<i> </i> $sql_query = 'UPDATE users SET ';//Half built the query. Now got to grab the Column Names (which need querying) that match the form Item Names.
<i> </i> foreach($form_questions_labels AS $form_question_label)
<i> </i> {
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>
<i> </i> if(isset($_POST["$value_2"]) && !empty($_POST["$value_2"]))
<i> </i> {
<i> </i> $sql_query = $sql_query . "$value_2 = ?, ";
<i> </i> }
<i> </i> }
<i> </i> $sql_query = $sql_query . 'WHERE id = ?;';
<i> </i> //Now below, need to fix the last part of the Mysql Tbl Query as query has been generated something like this with a comma after the final column name's placeholder. Eg. $sql_query = "UPDATE users SET first_name = ?, surname = ?, WHERE id = ?";
<i> </i> $value_3 = $sql_query;
<i> </i> $value_4 = str_replace("= ?, WHERE","= ? WHERE","$value_3");//Replaced the Comma after the final column name's placeholder.
<i> </i> $sql_query = $value_4;
<i> </i> echo "$sql_query<br>"; echo "Line:277<br>";
<i> </i> /*
<i> </i> if(!mysqli_prepare($conn,$query)
<i> </i> {
<i> </i> //Close Connection.
<i> </i> mysqli_close($conn);
<i> </i> echo "Line 322<br>";//DELETE THIS
<i> </i> die("<pre>Statement Execution Failed!n".mysqli_error($conn)."n$mysqli_stmt_bind_param</pre>");
<i> </i> }
<i> </i> */
<i> </i> //$sql_query = "UPDATE users SET first_name = ?, middle_name = ?, surname = ?, gender = ?, marital_status = ?, working_status = ? WHERE id = ?";
<i> </i> $stmt = mysqli_prepare($conn,$sql_query);
<i> </i> if($stmt == False)
<i> </i> {
<i> </i> //Close Connection.
<i> </i> mysqli_close($conn);
<i> </i> echo "Line 293<br>";//DELETE THIS
<i> </i> die("<pre>Mysqli Prepare Failed!n".mysqli_stmt_error($stmt)."n$sql_query</pre>");
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> //Generate the mysqli_stmt_bind_param() in parts to generate the variables matching the 'Column Names'.
<i> </i> $_SESSION["user_id"] = 13; //DELETE THIS LINE
<i> </i>
<i> </i> echo $mysqli_stmt_bind_param_part_1 = 'mysqli_stmt_bind_param($';
<i> </i> echo $mysqli_stmt_bind_param_part_2 = 'stmt,'ssssssi',';
<i> </i>
<i> </i> foreach($form_questions_labels AS $form_question_label)
<i> </i> {
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i> if($form_question_label == $form_questions_labels[0])
<i> </i> {
<i> </i> echo $mysqli_stmt_bind_param_part_3 = '$' . "$value_2,";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> echo $mysqli_stmt_bind_param_part_3 = "$mysqli_stmt_bind_param_part_3" . '$' . "$value_2,";
<i> </i> }
<i> </i> }
<i> </i> echo $mysqli_stmt_bind_param_part_4 = '$_SESSION["user_id"])';
<i> </i> echo $mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_1" . "$mysqli_stmt_bind_param_part_2" . "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4"; //Now Bind Param looks like this: mysqli_stmt_bind_param($stmt,'ssssssss',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,13);
<i> </i>
<i> </i> //EVEN WITH FOLLOWING LINE UNCOMMENTED, I STILL GET THE ERROR THAT I HAVE NOT SUPPLIED DATA TO PREPARED STATEMENT!
<i> </i> //mysqli_stmt_bind_param($stmt,'ssssssi',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,$_SESSION["user_id"]);
<i> </i> //Attempt to Execute the Prepared Statement.
<i> </i> mysqli_stmt_execute($stmt);
<i> </i> if(!mysqli_stmt_execute($stmt))
<i> </i> {
<i> </i> //Close Connection.
<i> </i> mysqli_close($conn);
<i> </i> echo "Line 322<br>";//DELETE THIS
<i> </i> die("<pre>Statement Execution Failed!n".mysqli_stmt_error($stmt)."n$mysqli_stmt_bind_param</pre>");
<i> </i> }
<i> </i> //mail();
<i> </i> }
<i> </i> }
<i> </i> }
<i> </i>}
}
echo "Line 337<br>";
echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
echo "Session Status:"; echo session_status(); echo "<br>";
?>
<?php
/*
session_start();
//$_session = 'search';
//echo session_id();
//echo $_session;
if(isset($_GET['session_type']))
{
$session=$_GET['session'];echo $_session['session'];
}
else
{
die("Invalid Session1!");echo $_session['session'];
}
*/
/*
echo session_id();
session_start();
if(isset($_GET['session_type']))
{
$_GET['session_type'];
}
else
{
die("Invalid Session2");
}
*/
?>
mysqli_stmt_bind_param()
<i>
</i>else
{
/*
Generate the mysqli_stmt_bind_param() in parts to generate the variables
matching the 'Column Names'.
*/
$_SESSION["user_id"] = 13; //DELETE THIS LINE
<i> </i>echo $mysqli_stmt_bind_param_part_1 = 'mysqli_stmt_bind_param($';
<i> </i>echo $mysqli_stmt_bind_param_part_2 = 'stmt,'ssssssi',';
<i> </i>
<i> </i>foreach($form_questions_labels AS $form_question_label)
<i> </i>{
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i> if($form_question_label == $form_questions_labels[0])
<i> </i> {
<i> </i> echo $mysqli_stmt_bind_param_part_3 = '$' . "$value_2,";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> echo $mysqli_stmt_bind_param_part_3 = "$mysqli_stmt_bind_param_part_3" .
<i> </i> '$' . "$value_2,";
<i> </i> }
}
echo $mysqli_stmt_bind_param_part_4 = '$_SESSION["user_id"])';
echo $mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_1" .
"$mysqli_stmt_bind_param_part_2" .
"$mysqli_stmt_bind_param_part_3" .
"$mysqli_stmt_bind_param_part_4"; //Now Bind Param looks like this: mysqli_stmt_bind_param($stmt,'ssssssss',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,13);
//EVEN WITH FOLLOWING LINE UNCOMMENTED, I STILL GET THE ERROR THAT I HAVE NOT SUPPLIED DATA TO PREPARED STATEMENT!
//mysqli_stmt_bind_param($stmt,'ssssssi',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,$_SESSION["user_id"]);
//Attempt to Execute the Prepared Statement.
mysqli_stmt_execute($stmt);
if(!mysqli_stmt_execute($stmt))
{
//Close Connection.
mysqli_close($conn);
echo "Line 322<br>";//DELETE THIS
die("<pre>Statement Execution Failed!n".mysqli_stmt_error($stmt)."n$mysqli_stmt_bind_param</pre>");
}
//mail();
}
<i>
</i>echo $mysqli_stmt_bind_param_part_4 = '$_SESSION["user_id"])';
echo $mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_1" . "$mysqli_stmt_bind_param_part_2" . "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4";
//Now Bind Param looks like this: mysqli_stmt_bind_param($stmt,'ssssssss',$first_name,$middle_name,$surname,$gender,
$marital_status,$working_status,13);
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,$_SESSION["user_id"]);
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param_part_3,$_SESSION["user_id"]);
<i>
</i>//Generate the mysqli_stmt_bind_param() in parts to generate the variables matching the 'Column Names'.
$_SESSION["user_id"] = 13; //DELETE THIS LINE
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
if($form_question_label == $form_questions_labels[0])
{
echo $mysqli_stmt_bind_param_part_3 = '$' . "$value_2,";
}
else
{
echo $mysqli_stmt_bind_param_part_3 = "$mysqli_stmt_bind_param_part_3" . '$' . "$value_2,";
}
}
mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param_part_3,$_SESSION["user_id"]);
<i>
</i>//Generate the mysqli_stmt_bind_param() in parts to generate the variables matching the 'Column Names'.
$_SESSION["user_id"] = 13; //DELETE THIS LINE
echo $mysqli_stmt_bind_param_part_1 = 'mysqli_stmt_bind_param($';
echo $mysqli_stmt_bind_param_part_2 = 'stmt,'ssssssi',';
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i> if($form_question_label == $form_questions_labels[0])
<i> </i> {
<i> </i> echo $mysqli_stmt_bind_param_part_3 = '$' . "$value_2,";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> echo $mysqli_stmt_bind_param_part_3 = "$mysqli_stmt_bind_param_part_3" . '$' . "$value_2,";
<i> </i> }
}
echo $mysqli_stmt_bind_param_part_4 = '$_SESSION["user_id"]);';
echo $mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_1" . "$mysqli_stmt_bind_param_part_2" . "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4"; //Now Bind Param looks like this: mysqli_stmt_bind_param($stmt,'ssssssss',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,13);
//mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param_part_3,$_SESSION["user_id"]);
mysqli_stmt_bind_param($mysqli_stmt_bind_param);
<i>
</i>foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
if($form_question_label == $form_questions_labels[0])
{
echo $mysqli_stmt_bind_param_part_3 = '$' . "$value_2,";
}
else
{
echo $mysqli_stmt_bind_param_part_3 = "$mysqli_stmt_bind_param_part_3" . '$' . "$value_2,";
}
}
echo $mysqli_stmt_bind_param_part_4 = '$_SESSION["user_id"]);';
//echo $mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_1" . "$mysqli_stmt_bind_param_part_2" . "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4"; //Now Bind Param looks like this: mysqli_stmt_bind_param($stmt,'ssssssss',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,13);
echo $mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4"; //Now Bind Param looks like this: mysqli_stmt_bind_param($stmt,'ssssssss',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,13);
mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param,$_SESSION["user_id"]);
<i>
</i>$sql_query = "UPDATE users SET first_name = ?, middle_name = ?, surname = ?, gender = ?, marital_status = ?, working_status = ? WHERE id = ?";
$stmt = mysqli_prepare($conn,$sql_query);
if($stmt == False)
{
//Close Connection.
mysqli_close($conn);
echo "Line 293<br>";//DELETE THIS
die("<pre>Mysqli Prepare Failed!n".mysqli_stmt_error($stmt)."n$sql_query</pre>");
}
else
{
//Generate the mysqli_stmt_bind_param() in parts to generate the variables matching the 'Column Names'.
$_SESSION["user_id"] = 13;
<i> </i> mysqli_stmt_bind_param($stmt,'ssssssi',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,$_SESSION["user_id"]);
<i> </i> //Attempt to Execute the Prepared Statement.
<i> </i> mysqli_stmt_execute($stmt);
<i> </i> if(!mysqli_stmt_execute($stmt))
<i> </i> {
<i> </i> //Close Connection.
<i> </i> mysqli_close($conn);
<i> </i> echo "Line 322<br>";//DELETE THIS
<i> </i> die("<pre>Statement Execution Failed!n".mysqli_stmt_error($stmt)."n$mysqli_stmt_bind_param</pre>");
<i> </i> }
}
<i>
</i>if(!mysqli_stmt_execute($stmt))
{
//Close Connection.
mysqli_close($conn);
echo "Line 322<br>";//DELETE THIS
die("<pre>Statement Execution Failed!n".mysqli_stmt_error($stmt)."n$mysqli_stmt_bind_param</pre>");
}
<i>
</i>$conn = mysqli_connect("localhost","root","","powerpage");
$conn->set_charset('utf8mb4'); //Always set Charset.
$sql_query = "UPDATE users SET first_name = ?, middle_name = ?, surname = ?, gender = ?, marital_status = ?, working_status = ? WHERE id = ?";
$stmt = mysqli_prepare($conn,$sql_query);
<i>
</i><?php
error_reporting(E_ALL);
?>
<!DOCTYPE HTML">
<html>
<head>
<meta name="viewport" content="width-device=width, initial-scale=1">
</head>
<body>
<?php
if(session_id() == '')
{
echo "Line 16 <br>";
echo "Session Status:"; echo session_status(); echo "<br>";
session_start();
$_SESSION['session_step'] = 'start';
echo "Line 21 <br>";
echo "Session Status:"; echo session_status(); echo "<br>";
echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
}
if($_SESSION['session_step'] != 'end');
{
echo "Line 28 <br>";
echo "Session Status:"; echo session_status(); echo "<br>";
echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
<i> </i>if(isset($_GET['session_type']) && !empty($_GET['session_type']))
<i> </i>{
<i> </i> $_SESSION['session_type'] = $_GET['session_type'];
<i> </i> //echo session_id();
<i> </i> if(!function_exists($_SESSION['session_type']))
<i> </i> {
<i> </i> die("Invalid Session");
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> echo "Line 42<br>";//THIS LINE SHOULD NOT ECHO AFTER CLICKING THE SUBMIT BUTTON SINCE 1). IT IS BEFORE THE SUBMIT BUTTON IN THE SCRIPT FLOW. AND 2). AFTER CLICKING THE SUBMIT BUTTON $_SESSION['session_step'] = 'end';! THIS LINE SHOULD ONLY ECHO IF $_SESSION['session_step'] = 'start'; WHY IS THIS LINE ECHOING AFTER CLICKING THE SUBMIT BUTTON ?
<i> </i> echo "Session Status:"; echo session_status(); echo "<br>";
<i> </i> echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
<i> </i> $_SESSION['session_type']();
<i> </i> }
<i> </i>}
<i> </i>else
<i> </i>{
<i> </i> die("Invalid Session");
<i> </i>}
<i> </i>function submit_personal_details()
<i> </i>{
<i> </i> $session_type = $_SESSION['session_type'];
<i> </i>
<i> </i> $form_questions_labels[]='First Name';
<i> </i> $form_questions_labels[]='Middle Name';
<i> </i> $form_questions_labels[]='Surname';
<i> </i> $form_questions_labels[]='Gender';
<i> </i> //$form_questions_labels[]='Age_Range';
<i> </i> $form_questions_labels[]='Marital Status';
<i> </i> $form_questions_labels[]='Working Status';
<i> </i>
<i> </i> $form_questions_labels_required[]='First Name';
<i> </i> $form_questions_labels_required[]='Surname';
<i> </i> $form_questions_labels_required[]='Gender';
<i> </i> //$form_questions_labels_required[]='Age_Range';
<i> </i> $form_questions_labels_required[]='Marital Status';
<i> </i> $form_questions_labels_required[]='Working Status';
<i> </i>
<i> </i> $text_fields_labels = array('First Name','Middle Name','Surname');
<i> </i> $radio_buttons_labels = array('Gender');
<i> </i> $drop_downs_labels = array('Marital Status','Working Status');
<i> </i> /*
<i> </i> $i=1;
<i> </i> $options_radio_button_[$i] = array('Male','Female','Male To Female','Female To Male');
<i> </i> $i=2;
<i> </i> $options_radio_button_[$i] = array('Yes','No');
<i> </i> */
<i> </i> /*
<i> </i> $i=1;
<i> </i> $options_drop_down_[$i] = array('Single','Married','Divorced','Widow');
<i> </i> $i=2;
<i> </i> $options_drop_down_[$i] = array('Selfemployed','Employed','Unemployed');
<i> </i> */
<i> </i> //Gender Options
<i> </i> $i=1;
<i> </i> $options_radio_button_[$i][]='Male';
<i> </i> $options_radio_button_[$i][]='Female';
<i> </i> $options_radio_button_[$i][]='Male To Female';
<i> </i> $options_radio_button_[$i][]='Female To Male';
<i> </i> $total_options_radio_button_[$i] = count($options_radio_button_[$i]);//4
<i> </i> /*
<i> </i> //Tos Options
<i> </i> $i=2;
<i> </i> $options_radio_button_[$i][]='Yes';
<i> </i> $options_radio_button_[$i][]='No';
<i> </i> $total_options_radio_button_[$i] = count($options_radio_button_[$i]);//2
<i> </i> */
<i> </i> //Marital Status Options
<i> </i> $i=1;
<i> </i> $options_drop_down_[$i][]='Single';
<i> </i> $options_drop_down_[$i][]='Married';
<i> </i> $options_drop_down_[$i][]='Divorced';
<i> </i> $options_drop_down_[$i][]='Widow';
<i> </i> $total_options_drop_down_[$i] = count($options_drop_down_[$i]);//4
<i> </i> //Working Status Options
<i> </i> $i=2;
<i> </i> $options_drop_down_[$i][]='Selfemployed';
<i> </i> $options_drop_down_[$i][]='Employed';
<i> </i> $options_drop_down_[$i][]='Unemployed';
<i> </i> $total_options_drop_down_[$i] = count($options_drop_down_[$i]);//3
<i> </i> $total_form_questions_labels = 8;
<i> </i> $total_form_questions_labels_required = 7;
<i> </i> $total_text_fields_labels = 4;
<i> </i> $total_radio_buttons_labels = count($radio_buttons_labels);//2
<i> </i> $total_drop_downs_labels = count($drop_downs_labels);//2
<i> </i> ?>
<i> </i> <form action="<?php echo $_SERVER['PHP_SELF'];?>?session_type=<?php echo $_SESSION['session_type'];?>" method="post" enctype="plain/text">
<i> </i> <?php
<i> </i> foreach($form_questions_labels as $form_question_label) //Loop through the whole 'Form Questions' array.
<i> </i> {
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>
<i> </i> //Check if current 'Form Item' is a 'Text Field' or not.
<i> </i> if(in_array("$form_question_label",$text_fields_labels)) //Current 'Form Item' proved to be a 'Text Field'.
<i> </i> {
<i> </i> //Check if current 'Form Item' (Text Field) is a 'required' one or not.
<i> </i> if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Text Field) proved to be a 'required' one.
<i> </i> {
<i> </i> //Added '*' (asterisk) to indicate the 'Text Field' is a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label *:</label>
<i> </i> <input type="text" name="$value_2" placeholder="$form_question_label" value = "">";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> //Added no '*' (asterisk) to indicate the 'Text Field' is NOT a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label:</label>
<i> </i> <input type="text" name="$value_2" placeholder="$form_question_label">";
<i> </i> }
<i> </i> echo "<br>";
<i> </i> }
<i> </i> //Check if current 'Form Item' is a 'Radio Button' or not.
<i> </i> if(in_array("$form_question_label",$radio_buttons_labels)) //Current 'Form Item' proved to be a 'Radio Button'.
<i> </i> {
<i> </i> //Check if current 'Form Item' (Radio Button) is a 'required' one or not.
<i> </i> if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Radio Button) proved to be a 'required' one.
<i> </i> {
<i> </i> //Added '*' (asterisk) to indicate the 'Radio Button' is a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label *:</label>";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> //Added no '*' (asterisk) to indicate the 'Radio Button' is NOT a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label:</label>";
<i> </i> }
<i> </i> $i = 0;
<i> </i> foreach($radio_buttons_labels as $radio_button_label) //$radio_buttons_labels = ('Gender','Tos');
<i> </i> {
<i> </i> if($form_question_label == $radio_button_label) //eg. 'Gender'.
<i> </i> {
<i> </i> $i++;
<i> </i> foreach($options_radio_button_[$i] as $option_radio_button_[$i])
<i> </i> {
<i> </i> echo "<input type="radio" id="$option_radio_button_[$i]" name="$value_2" value="$option_radio_button_[$i]">
<i> </i> <label_for="$option_radio_button_[$i]">$option_radio_button_[$i]</label>";
<i> </i> }
<i> </i> echo "<br>";
<i> </i> }
<i> </i> $i++;
<i> </i> }
<i> </i> }
<i> </i> //Check if current 'Form Item' is a 'Drop Down' or not.
<i> </i> if(in_array("$form_question_label",$drop_downs_labels)) //Current 'Form Item' proved to be a 'Drop Down'.
<i> </i> {
<i> </i> //Check if current 'Form Item' (Drop Down) is a 'required' one or not.
<i> </i> if(in_array("$form_question_label",$form_questions_labels_required))//Current 'Form Item' (Drop Down) proved to be a 'required' one.
<i> </i> {
<i> </i> //Added '*' (asterisk) to indicate the 'Drop Down' is a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label *:</label>";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> //Added no '*' (asterisk) to indicate the 'Drop Down' is NOT a 'required' one.
<i> </i> echo "<label for="$value_2">$form_question_label:</label>";
<i> </i> }
<i> </i> $i = 0;
<i> </i> foreach($drop_downs_labels as $drop_down_label)//$drop_downs_labels = ('Marital Status','Working Status');
<i> </i> {
<i> </i> if($form_question_label == $drop_down_label)
<i> </i> {
<i> </i> $i++;
<i> </i> echo "<select name="$value_2">";
<i> </i> echo "<option value="$option_drop_down_[$i]">$option_drop_down_[$i]</option>";
<i> </i> foreach($options_drop_down_[$i] as $option_drop_down_[$i])
<i> </i> {
<i> </i> echo "<option value="$option_drop_down_[$i]">$option_drop_down_[$i]</option>";
<i> </i> }
<i> </i> echo "</select>";
<i> </i> echo "<br>";
<i> </i> }
<i> </i> $i++;
<i> </i> }
<i> </i> }
<i> </i> }
<i> </i> ?>
<i> </i> <input type="submit" name="submit_personal_details" value="Submit">
<i> </i> <?php
<i> </i> //$current_function = __FUNCTION__;
<i> </i> //echo $current_function;
<i> </i>
<i> </i> if($_SERVER['REQUEST_METHOD'] === 'POST')
<i> </i> {echo "Line 217<br>";
<i> </i> if(isset($_POST['submit_personal_details']) && $_SESSION['session_step'] != 'end')
<i> </i> {
<i> </i> $_SESSION['session_step'] = 'end';
<i> </i> echo "Line 223<br>";
<i> </i> echo "Session Status:"; echo session_status(); echo "<br>";
<i> </i> echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
<i> </i> foreach($form_questions_labels_required AS $form_question_label_required)
<i> </i> {
<i> </i> $value = $form_question_label_required;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>
<i> </i> if(!isset($_POST["$value_2"]) || trim ($_POST["$value_2"]) === '')//Do not use 'empty($_POST["$value_2"]))' here as a '0' value is considered 'empty' value.
<i> </i> {
<i> </i> echo "Fill-in All required Form Fields that! Fields with asterisks * are required to be filled-in!<br>";
<i> </i> //die("Fill-in All required Form Fields that! Fields with asterisks * are required to be filled-in!");
<i> </i> }
<i> </i> /*
<i> </i> else
<i> </i> {
<i> </i> echo "$value_2<br>"; echo "Line 227!<br>";
<i> </i> }
<i> </i> */
<i> </i> }
<i> </i> echo "Line 242<br>";
<i> </i> echo "Session Status:"; echo session_status(); echo "<br>";
<i> </i> echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
<i> </i> session_destroy();
<i> </i> echo "Line 246<br>";
<i> </i> echo "Session Status:"; echo session_status(); echo "<br>";
<i> </i> echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
<i> </i>
<i> </i> //Connect to Database. (DB_SERVER, BD_USERNAME, DB_PASSWORD, DB_NAME).
<i> </i> $conn = mysqli_connect("localhost","root","","powerpage");
<i> </i> $conn->set_charset('utf8mb4'); //Always set Charset.
<i> </i>
<i> </i> if($conn === false)
<i> </i> {
<i> </i> die("ERROR: Connection Error!. " . mysqli_connect_error());
<i> </i> }
<i> </i>
<i> </i> //Prepare an UPDATE Statement.
<i> </i> $sql_query = 'UPDATE users SET ';//Half built the query. Now got to grab the Column Names (which need querying) that match the form Item Names.
<i> </i> foreach($form_questions_labels AS $form_question_label)
<i> </i> {
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>
<i> </i> if(isset($_POST["$value_2"]) && !empty($_POST["$value_2"]))
<i> </i> {
<i> </i> $sql_query = $sql_query . "$value_2 = ?, ";
<i> </i> }
<i> </i> }
<i> </i> $sql_query = $sql_query . 'WHERE id = ?;';
<i> </i> //Now below, need to fix the last part of the Mysql Tbl Query as query has been generated something like this with a comma after the final column name's placeholder. Eg. $sql_query = "UPDATE users SET first_name = ?, surname = ?, WHERE id = ?";
<i> </i> $value_3 = $sql_query;
<i> </i> $value_4 = str_replace("= ?, WHERE","= ? WHERE","$value_3");//Replaced the Comma after the final column name's placeholder.
<i> </i> $sql_query = $value_4;
<i> </i> echo "$sql_query<br>"; echo "Line:277<br>";
<i> </i> /*
<i> </i> if(!mysqli_prepare($conn,$query)
<i> </i> {
<i> </i> //Close Connection.
<i> </i> mysqli_close($conn);
<i> </i> echo "Line 322<br>";//DELETE THIS
<i> </i> die("<pre>Statement Execution Failed!n".mysqli_error($conn)."n$mysqli_stmt_bind_param</pre>");
<i> </i> }
<i> </i> */
<i> </i> $sql_query = "UPDATE users SET first_name = ?, middle_name = ?, surname = ?, gender = ?, marital_status = ?, working_status = ? WHERE id = ?";
<i> </i> $stmt = mysqli_prepare($conn,$sql_query);
<i> </i> if($stmt == False)
<i> </i> {
<i> </i> //Close Connection.
<i> </i> mysqli_close($conn);
<i> </i> echo "Line 293<br>";//DELETE THIS
<i> </i> die("<pre>Mysqli Prepare Failed!n".mysqli_stmt_error($stmt)."n$sql_query</pre>");
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> //Generate the mysqli_stmt_bind_param() in parts to generate the variables matching the 'Column Names'.
<i> </i> $_SESSION["user_id"] = 13; //DELETE THIS LINE
<i> </i>
<i> </i> /*
<i> </i> foreach($form_questions_labels AS $form_question_label)
<i> </i> {
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i> if($form_question_label == $form_questions_labels[0])
<i> </i> {
<i> </i> echo $mysqli_stmt_bind_param_part_3 = '$' . "$value_2,";
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> echo $mysqli_stmt_bind_param_part_3 = "$mysqli_stmt_bind_param_part_3" . '$' . "$value_2,";
<i> </i> }
<i> </i> }
<i> </i> echo $mysqli_stmt_bind_param_part_4 = '$_SESSION["user_id"]);';
<i> </i> */
<i> </i>
<i> </i> /*
<i> </i> echo $mysqli_stmt_bind_param_part_1 = 'mysqli_stmt_bind_param($';
<i> </i> echo $mysqli_stmt_bind_param_part_2 = 'stmt,'ssssssi',';
<i> </i> echo $mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_1" . "$mysqli_stmt_bind_param_part_2" . "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4"; //Now Bind Param looks like this: mysqli_stmt_bind_param($stmt,'ssssssss',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,13);
<i> </i> mysqli_stmt_bind_param($mysqli_stmt_bind_param);
<i> </i> */
<i> </i>
<i> </i> /*
<i> </i> echo $mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4"; //Now Bind Param looks like this: mysqli_stmt_bind_param($stmt,'ssssssss',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,13);
<i> </i> mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param,$_SESSION["user_id"]);
<i> </i> */
<i> </i> echo "Line 330<br>";
<i> </i> mysqli_stmt_bind_param($stmt,'ssssssi',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,$_SESSION["user_id"]);
<i> </i> //Attempt to Execute the Prepared Statement.
<i> </i> mysqli_stmt_execute($stmt);
<i> </i> if(!mysqli_stmt_execute($stmt))
<i> </i> {
<i> </i> //Close Connection.
<i> </i> mysqli_close($conn);
<i> </i> echo "Line 322<br>";//DELETE THIS
<i> </i> die("<pre>Statement Execution Failed!n".mysqli_stmt_error($stmt)."n$mysqli_stmt_bind_param</pre>");
<i> </i> }
<i> </i> //mail();
<i> </i> }
<i> </i> }
<i> </i> }
<i> </i>}
}
echo "Line 337<br>";
echo "Session Step:"; echo $_SESSION['session_step']; echo "<br>";
echo "Session Status:"; echo session_status(); echo "<br>";
?>
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,$_SESSION["user_id"]);
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',$_POST['first_name'],$_POST['middle_name'],$_POST['surname'],$_POST['gender'],$_POST['marital_status'],$_POST['working_status'],$_SESSION["user_id"]);
<i>
</i>some_function($foo, $bar) { . . . }
// ..is not the same as...
$fubar = "$foo, $bar";
some_function($fubar) { . . . }
call_user_func_array()
<i>
</i>$args = array(
$conn,
'ssssi',
$val1,
$val2,
$val3,
$val4,
$val5
);
call_user_func_array('mysqli_stmt_bind_param', $args);
<i>
</i>mysqli_stmt_bind_param($stmt,'sss',$_POST['first_name'],$_POST['middle_name'],$_POST['surname'],$user_id']);
<i>
</i>mysqli_stmt_bind_param($stmt,'ss',$_POST['first_name'],$_POST['surname'],$user_id']);
<i>
</i>if($_POST['title'] == '') && $_POST['middle_name'] == ''))
{
mysqli_stmt_bind_param($stmt,'sss',$_POST['first_name'],$_POST['surname'],$user_id']);
}
elseif($_POST['title'] == '')
{
mysqli_stmt_bind_param($stmt,'ssss',$_POST['first_name'],$_POST['middle_name'],$_POST['surname'],$user_id']);
}
if($_POST['middle_name'] == '')
{
mysqli_stmt_bind_param($stmt,'ssss',$_POST['title'],$_POST['first_name'],$_POST['surname'],$user_id']);
}
<i>
</i>$form_questions_labels[]='Title';
$form_questions_labels[]='First Name';
$form_questions_labels[]='Middle Name';
$form_questions_labels[]='Surname';
$form_questions_labels[]='Gender';
$form_questions_labels[]='Marital Status';
$form_questions_labels[]='Working Status';
$form_questions_labels_required[]='First Name';
$form_questions_labels_required[]='Surname';
$form_questions_labels_required[]='Gender';
$form_questions_labels_required[]='Marital Status';
$form_questions_labels_required[]='Working Status';
if($conn === false)
{
die("ERROR: Connection Error!. " . mysqli_connect_error());
}
//Prepare an UPDATE Statement.
$sql_query = 'UPDATE users SET ';//Half built the query here. Now got to grab the Column Names (which need querying) that match the form Item Names.
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>if(isset($_POST["$value_2"]) && !empty($_POST["$value_2"]))
<i> </i>{
<i> </i> $sql_query = $sql_query . "$value_2 = ?, ";
<i> </i>}
}
$sql_query = $sql_query . 'WHERE id = ?;';
//Now below, need to fix the last part of the Mysql Tbl Query as query has been generated something like this with a comma after the final column name's placeholder. Eg. $sql_query = "UPDATE users SET first_name = ?, surname = ?, WHERE id = ?";
$value_3 = $sql_query;
$value_4 = str_replace("= ?, WHERE","= ? WHERE","$value_3");//Replaced the Comma after the final column name's placeholder.
$sql_query = $value_4;
echo "$sql_query<br>"; echo "Line:277<br>";
$stmt = mysqli_prepare($conn,$sql_query);
if($stmt == False)
{
//Close Connection.
mysqli_close($conn);
echo "Line 293<br>";//DELETE THIS
die("<pre>Mysqli Prepare Failed!n".mysqli_stmt_error($stmt)."n$sql_query</pre>");
}
else
{
//Generate the mysqli_stmt_bind_param() in parts to generate the variables matching the 'Column Names'.
$_SESSION["user_id"] = 13; //DELETE THIS LINE AFTER DEV MODE IS COMPLETE
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i> if($form_question_label == $form_questions_labels[0])
<i> </i> {
<i> </i> $mysqli_stmt_bind_param_part_3 = '$_POST["' . $value_2 . '"],';
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> $mysqli_stmt_bind_param_part_3 = "$mysqli_stmt_bind_param_part_3" . '$_POST["' . $value_2 . '"],';
<i> </i> }
<i> </i> }
echo $mysqli_stmt_bind_param_part_4 = '$_SESSION["user_id"]);';
echo $mysqli_stmt_bind_param_3_4 = "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4";
echo $mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4"; //Now Bind Param looks something like this: mysqli_stmt_bind_param($stmt,'ssssssss',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,13);
mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param);
//Attempt to execute the Prepared Statement.
if(!mysqli_stmt_execute($stmt))
{
//Close Connection.
mysqli_close($conn);
<i> </i>die("Could not update! Please try again later!");
}
echo "Line 330<br>";
echo $_SESSION['user_id']; echo "<br>";
//mysqli_stmt_bind_param($stmt,'ssssssi',$_POST['first_name'],$_POST['middle_name'],$_POST['surname'],$_POST['gender'],$_POST['marital_status'],$_POST['working_status'],$_SESSION["user_id"]);
//Attempt to Execute the Prepared Statement.
mysqli_stmt_execute($stmt);
if(!mysqli_stmt_execute($stmt))
{
//Close Connection.
mysqli_close($conn);
echo "Line 322<br>";//DELETE THIS
die("<pre>Statement Execution Failed!n".mysqli_stmt_error($stmt)."n$mysqli_stmt_bind_param_3_4</pre>");
}
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param_part_3_4);
<i>
</i>$mysqli_stmt_bind_param_part_3_4);
<i>
</i>$_POST['first_name'],$_POST['middle_name'],$_POST['surname'],$_POST['gender'],$_POST['marital_status'],$_POST['working_status'],$_SESSION['user_id']
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param_part_3_4);
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',,$_POST['surname'],$_POST['gender'],$_POST['marital_status'],$_POST['working_status'],$_SESSION['user_id']);
<i>
</i>$mysqli_stmt_bind_param_part_3_4
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',,$_POST['surname'],$_POST['gender'],$_POST['marital_status'],$_POST['working_status'],$_SESSION['user_id']);
'ssssssi'
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',,$_POST['surname'],$_POST['gender'],$_POST['marital_status'],$_POST['working_status'],$_SESSION['user_id']);
<i>
</i>$_POST['first_name'];
$_POST['middle_name'];
$_POST['surname'];
$_POST['gender'];
$_POST['marital_status'];
$_POST['working_status'];
$_SESSION['user_id'];
<i>
</i>$user_id = $_SESSION['user_id'];
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',$_POST['first_name'],$_POST['middle_name'],$_POST['surname'],$_POST['gender'],$_POST['marital_status'],$_POST['working_status'],$_SESSION['user_id']);
<i>
</i>$user_id = $_SESSION['user_id'];
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',$_POST['first_name'],$_POST['middle_name'],$_POST['surname'],$_POST['gender'],$_POST['marital_status'],$_POST['working_status'],$_SESSION['user_id']);
<i>
</i>'ssssssi'
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',$_POST['first_name'],$_POST['middle_name'],$_POST['surname'],$_POST['gender'],$_POST['marital_status'],$_POST['working_status'],$_SESSION['user_id']);
<i>
</i>
$form_questions_labels[]='First Name';
$form_questions_labels[]='Middle Name';
$form_questions_labels[]='Surname';
$form_questions_labels[]='Gender';
$form_questions_labels[]='Marital Status';
$form_questions_labels[]='Working Status';
$form_questions_labels_required[]='First Name';
$form_questions_labels_required[]='Surname';
$form_questions_labels_required[]='Gender';
$form_questions_labels_required[]='Marital Status';
$form_questions_labels_required[]='Working Status';
//Generate the mysqli_stmt_bind_param() in parts to generate the variables matching the 'Column Names'.
$_SESSION["user_id"] = 13; //DELETE THIS LINE
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
if($form_question_label == $form_questions_labels[0])
{
$mysqli_stmt_bind_param_part_3 = '$_POST["' . $value_2 . '"],';
}
else
{
$mysqli_stmt_bind_param_part_3 = "$mysqli_stmt_bind_param_part_3" . '$_POST["' . $value_2 . '"],';
}
}
echo $mysqli_stmt_bind_param_part_4 = '$_SESSION["user_id"]);';
echo $mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4"; //Now Bind Param looks like this: mysqli_stmt_bind_param($stmt,'ssssssss',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,13);
mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param);
<i>
</i>'ssssssi'
<i>
</i>$_POST['first_name']; //string
$_POST['middle_name']; //string
$_POST['surname']; //string
$_POST['gender']; //string
$_POST['marital_status']; //string
$_POST['working_status']; //string
$_SESSION['user_id']; //INT
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param);
<i>
</i>//Prepare an UPDATE Statement.
$sql_query = 'UPDATE users SET ';//Half built the query. Now got to grab the Column Names (which need querying) that match the form Item Names.
foreach($form_questions_labels AS $form_question_label)
{
$value = $form_question_label;
$value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
$value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i>if(isset($_POST["$value_2"]) && !empty($_POST["$value_2"]))
<i> </i>{
<i> </i> $sql_query = $sql_query . "$value_2 = ?, ";
<i> </i>}
}
$sql_query = $sql_query . 'WHERE id = ?;';
//Now below, need to fix the last part of the Mysql Tbl Query as query has been generated something like this with a comma after the final column name's placeholder. Eg. $sql_query = "UPDATE users SET first_name = ?, surname = ?, WHERE id = ?";
$value_3 = $sql_query;
$value_4 = str_replace("= ?, WHERE","= ? WHERE","$value_3");//Replaced the Comma after the final column name's placeholder.
$sql_query = $value_4;
echo "SQL Query: $sql_query<br>"; echo "Line:277<br>";
$stmt = mysqli_prepare($conn,$sql_query);
if($stmt == False)
{
//Close Connection.
mysqli_close($conn);
echo "Line 293<br>";//DELETE THIS
die("<pre>Mysqli Prepare Failed!n".mysqli_stmt_error($stmt)."n$sql_query</pre>");
}
else
{
//Generate the mysqli_stmt_bind_param() in parts to generate the variables matching the 'Column Names'.
$_SESSION["user_id"] = 13; //DELETE THIS LINE
<i> </i>foreach($form_questions_labels AS $form_question_label)
<i> </i>{
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i> if($form_question_label == $form_questions_labels[0])
<i> </i> {
<i> </i> $mysqli_stmt_bind_param_part_3 = '$_POST["' . $value_2 . '"],';
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> $mysqli_stmt_bind_param_part_3 = "$mysqli_stmt_bind_param_part_3" . '$_POST["' . $value_2 . '"],';
<i> </i> }
<i> </i>}
<i> </i> echo $mysqli_stmt_bind_param_part_4 = '$_SESSION["user_id"]);';
$stmt = mysqli_prepare($conn,$sql_query);
if($stmt == False)
{
//Close Connection.
mysqli_close($conn);
echo "Line 293<br>";//DELETE THIS
die("<pre>Mysqli Prepare Failed!n".mysqli_stmt_error($stmt)."n$sql_query</pre>");
}
else
{
//Generate the mysqli_stmt_bind_param() in parts to generate the variables matching the 'Column Names'.
$_SESSION["user_id"] = 13; //DELETE THIS LINE
<i> </i>foreach($form_questions_labels AS $form_question_label)
<i> </i>{
<i> </i> $value = $form_question_label;
<i> </i> $value_1 = str_replace(" ","_","$value"); //Replaced Spaces to Underscores.
<i> </i> $value_2 = strtolower("$value_1"); //Replaced Upper Case to Lower Case.
<i> </i> if($form_question_label == $form_questions_labels[0])
<i> </i> {
<i> </i> $mysqli_stmt_bind_param_part_3 = '$_POST["' . $value_2 . '"],';
<i> </i> }
<i> </i> else
<i> </i> {
<i> </i> $mysqli_stmt_bind_param_part_3 = "$mysqli_stmt_bind_param_part_3" . '$_POST["' . $value_2 . '"],';
<i> </i> }
<i> </i>}
echo $mysqli_stmt_bind_param_part_4 = '$_SESSION["user_id"]);';
echo $mysqli_stmt_bind_param = "$mysqli_stmt_bind_param_part_3" . "$mysqli_stmt_bind_param_part_4"; //Now Bind Param looks like this: mysqli_stmt_bind_param($stmt,'ssssssi',$first_name,$middle_name,$surname,$gender,$marital_status,$working_status,13);
mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param);
echo "Line 330<br>";
echo $_SESSION['user_id']; echo "<br>";
//Attempt to Execute the Prepared Statement.
mysqli_stmt_execute($stmt);
if(!mysqli_stmt_execute($stmt))
{
//Close Connection.
mysqli_close($conn);
echo "Line 322<br>";//DELETE THIS
die("<pre>Statement Execution Failed!n".mysqli_stmt_error($stmt)."n$mysqli_stmt_bind_param</pre>");
}
}
<i>
</i>mysqli_stmt_bind_param($stmt,'ssssssi',$mysqli_stmt_bind_param);