I am stymied by this and no SO posts mention this so I’m asking for some thoughts here. In essence, I have a evaluation survey with 13 questions and the data are stored on a single row using 13 columns (q1-q13). I extract the row and then iterate through each column looking for responses matching 3 or 2 or 1. When found, I write a row into an array using array_push. This works perfectly for columns 1-9 but it fails on the 10th. I copied/paste each line of code and made simple edits so, technically, each line of code is identical so I see no reason why it should fail. What am I missing here?
function get_POTENTIAL_List($sc_id) {
global $dbc;
$pot_list = [];
$sql = "SELECT q1, q2, q3, q4, q5, q6, q7, q8, q9, q10, q11, q12, q13 FROM worksheetA WHERE emp_id = ?";
$stmt = prepared_query($dbc, $sql, [$sc_id]);
$row = $stmt->get_result()->fetch_assoc();
Then I use this code to build the aray:
if($row['q1'] == "3" || $row['q1'] == "2" || $row['q1'] == "1") {
$pot_info = array('id' => "1", 'category_title' => "INTRAPERSONAL/INTERPERSONAL", 'scale' => $row['q1'], 'scale_def' => "Scale Definition here.");
array_push($pot_list, $pot_info);
}
if($row['q2'] == "3" || $row['q2'] == "2" || $row['q2'] == "1") {
$pot_info = array('id' => "2", 'category_title' => "INTRAPERSONAL/INTERPERSONAL", 'scale' => $row['q2'], 'scale_def' => "Scale Definition here.");
array_push($pot_list, $pot_info);
}
and so on through (successfully) to 9:
if($row['q9'] == "3" || $row['q9'] == "2" || $row['q9'] == "1") {
$pot_info = array('id' => "9", 'category_title' => "INTRAPERSONAL/INTERPERSONAL", 'scale' => $row['q9'], 'scale_def' => "Scale Definition here.");
array_push($pot_list, $pot_info);
}
And then, on the 10th column it stops working with a
“Uncaught SyntaxError: Unexpected end of JSON input”
error.
if($row['q10'] == "3" || $row['q10'] == "2" || $row['q10'] == "1") {
$pot_info = array('id' => "10", 'category_title' => "INTRAPERSONAL/INTERPERSONAL", 'scale' => $row['q10'], 'scale_def' => "Scale Definition here.");
array_push($pot_list, $pot_info);
}