} } // Takes in user input and concatenates into a string to send to SQL for insertion function buildSQLString($tempArray) { $builtString = "CALL create_poll(1," . "'" . $tempArray[0][0] . "'," . "NULL," . "30,"; for ($i = 0; $i < count($tempArray); $i++) { for ($j = 1; $j < count($tempArray[$i]); $j++) { $builtString .= "'" . $tempArray[$i][$j] . "',"; } $builtString .= "NULL, NULL, NULL, NULL, NULL, NULL);"; } return $builtString; } //utilization of functions for debugging and insertion purposes $buffInArr = loadArray($incr1); printArray($buffInArr); $incr1++; //build SQL string statement $sqlInsertString = buildSQLString($buffInArr); $conn->close(); //$conn = new mysqli($servername, $username, $password, $dbname); //Display SQL string statement echo $sqlInsertString . "<br><br>"; //$conn->close(); $conn = new mysqli($servername, $username, $password, $dbname); //Attempt to insert data into database $insert = mysqli_query($conn, $sqlInsertString) or die("Query fail: " . mysqli_error()); $conn->close(); $conn = new mysqli($servername, $username, $password, $dbname); if ($conn->query($insert) === TRUE) {
$charArray[$k] = "\\'"; } $wordLoad .= $charArray[$k]; } $builtString .= "'" . $wordLoad . "');"; } else { $builtString .= "NULL);"; } } } } return $builtString; } //utilization of functions for insertion purposes $key = buildShareKey(); $sqlInsert = loadArray(); //Check if poll is public or private if (isset($_POST["pubOpriv"])) { //build SQL string statement $sqlInsertString = privatePoll($sqlInsert, $userID, $key, $categoryselection, $date); // echo '<br>' . $sqlInsertString . '<br>'; $insert = mysqli_query($conn, $sqlInsertString) or die("Query fail: " . mysqli_error()); $conn->close(); // echo "sent to private<br>"; // echo "<br> Share Key is: " . $key; } else { $conn = new mysqli($servername, $username, $password, $dbname); $sqlInsertString = publicPoll($sqlInsert, $userID, $categoryselection, $date); // echo '<br>' . $sqlInsertString . '<br>'; //Attempt to insert data into database $insert = mysqli_query($conn, $sqlInsertString) or die("Query fail: " . mysqli_error());