Código:
El código que tengo es esteWarning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, boolean given in /home/a9937565/public_html/HeadFirst/C8/questionnaire.php on line 32
Código PHP:
//If this user has never answered the questionnaire, insert empty responses into the database
$query = "SELECT * FROM mismatch_response WHERE user_id = '" . $_SESSION['user_id'] . "'";
$data = mysqli_query($dbc, $query);
if(mysqli_num_rows($data) == 0) {
//First grab the list of topic IDs from the topic table
$query = "SELECT topic_id FROM mismatch_topic ORDER BY category_id, topic_id";
$data = mysqli_query($dbc, $query);
$topicIDs = array();
while($row = mysqli_fetch_array($data)) {
array_push($topicIDs, $row['topic_id']);
}
//Insert empty response rows into the responsable table, one per topic
foreach($topicIDs as $topic_id) {
$query = "INSERT INTO mismatch_response (user_id, topic_id) VALUES ('" . $_SESSION['user_id'] . "', '$topic_id')";
mysqli_query($dbc, $query);
}
}
Código PHP:
while($row = mysqli_fetch_array($data)) {
array_push($topicIDs, $row['topic_id']);
}
EDITO: Ya he encontrado la solución, el fallo estaba en el segundo SELECT, en vez de poner category he puesto category_id