I am with this code without registration of age:



if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
echo "Connected successfully";
$result = $conn->query("SELECT FROM perguntas");
$data = array();
while($row = $result->fetch_assoc()){
and elgg is giving a critical error
  • Call to a member function fetch_array() on boolean in /mod/agerestriction/views/default/agerestriction/register.php:15\nStack trace:\n#0 elgg/elgg/engine/classes/Elgg/ViewsService.php(370):

  • Call to a member function fetch_array() on boolean mean that no data is returned from your query.

    I guess you forgot to add the column name in the query..

    SELECT `column 1` FROM perguntas
  • I have no idea what you are trying to achive, so just some general remarks:

    • register.php view of the Agerestriction plugin has no line 15. So, if you modified the code, you would need to post what you have changed in this view - the whole code of this file - or we don't know what might be the cause of the error.
    • Use Elgg API functions instead of trying to access the database directly with any PHP mysql functions. Not knowing what you want to do I can't tell you which function you would have to use here but there's very likely some function available.
    • The Agerestriction plugin does not save anything in the database. It just adds a checkbox input field to the registration page. The value of this field when submitting the register form (i.e. has the user who wants to create an account checked or not checked the field) is evaluated immediately after the submit. Only when the field got checked the account creation continues (done by Elgg core and no longer by Agerestriction plugin). Otherwise the user is brought back to the register form. But the value of the checkbox input field is not used any further when the account gets created. So, if you haven't made any further modifications to save the value the field had when the form got submitted you can't retrieve the value from the database.

    If you are trying to modify the Agerestriction plugin to display some other input fields (I think I remember you did ask for something along this) the question is if you want any of these values saved in the database or not. If yes, you would have to deal with that in the function agerestriction_register_hook() (or whatever you change the name to) in start.php. Nonetheless, the values won't be in the database yet if the user returns to the register form due to some missing or wrong input. But that's what the "sticky form" mechanism of Elgg is for. This is not used by the Agerestriction plugin on purpose as the user would explicitely have to confirm that he's old enough. But it's used by the Elgg core register form and you could make use of it also if you want to set the input field values to the previously set values if the register form hasn't been correctly filled up before.

    In the agerestriction_register_hook() function in start.php the form is already kept a sticky form by using elgg_make_sticky_form(). In the register.php view that extends the Elgg core register form you should be able to retrieve the value previouly set in the input field with the name attribute "fieldname"  with

    $fieldname_value = elgg_extract('fieldname', $vars);

    So, there's no need to try to retrieve anything from the database.