Where is the error? I can’t pull table from database!

Asked

Viewed 55 times

-1

 function getUserAccessRoleByID($id)
{
    global $conn;

    $query = "select user_role from tbl_user_role where  id = ".$id;

    $rs = mysqli_query($conn,$query);
    $row = mysqli_fetch_assoc($rs);

    return $row['user_role'];
}



function get_Pessoas()
{
    global $conn;

    $query = "select * from pessoas where id "; //query the db

    $rs = mysqli_query($conn,$query);
    $resArr = array(); //create the result array

    while($row = mysql_fetch_assoc($rs)) { //loop the rows returned from db
    $resArr[] = $row; //add row to array
}
echo '<pre>'; print_r($resArr); echo '</pre>';
return $resArr;   
}

  aqui puxo os resultados 

   <?php 

     $pessoas = get_Pessoas(); //get the result array

                    foreach($pessoas as $cond) { //loop the array
                        echo '<h1>'. $cond['cd_name']. '</h1>';
                        echo '<p>'. $cond['cd_idade']. '</p>';
                    }

                     ?>
  • select * from pessoas where id . What id ?

  • Do so, return query errors: $rs = mysqli_query($conn,$query) or die(mysqli_error($conn));

  • select * from people Where id referesr table id people --:id --:name --:phone

  • But does it make a mistake? If so, what mistake? And in which line?

  • Not from the online error but the whole page is blank as if it had not been loading anything or pulling anything.. errors do not return

  • Would not be $query = "select user_role from tbl_user_role where id = '$id'"; ? Another thing already commented is where id I believe it should be $query = "select * from pessoas"; to bring all the lines.

  • Fatal error: Uncaught Error: Call to Undefined Function mysql_fetch_assoc() in /var/www/server/

  • The functions mysql_* are obsolete and have been removed in PHP 7, what you probably want is mysqli_fetch_assoc with the i

  • Thank you the error was right here mysqli_fetch_assoc

Show 4 more comments

1 answer

0

while($Row = mysqli_fetch_assoc($rs)) the error was right here !

Browser other questions tagged

You are not signed in. Login or sign up in order to post.