What parameters to use in the mysql_fetch_array

Asked

Viewed 343 times

1

Hello, I don’t know which parameters(I only know one of them) to use in the mysql_fetch_array, please tell me what it is and how to get it.

    include "conection.php";

session_start(0);

$db = mysqli_connect("localhost", "root", "");
$login = $_SESSION['login_usuario'];

$sql = mysqli_query($db, "SELECT * FROM usuarios WHERE login = '$login'");

while($linha = mysql_fetch_array($sql, $sql))
{
    $nome = $linha['nome'];
    $email = $linha['email'];
    $idade = $linha['idade'];
    $cidade = $linha['cidade'];
}

Grateful from now on.

  • 2

    Have you looked at the documentation? mysqli_fetch_array. Avoid using functions mysql_*.

  • Yes, I’ve read it, but I don’t understand it :c

  • What exactly don’t you understand?

  • "The type of array that should be obtained. is a constant and can have the following values: MYSQL_ASSSOC, MYSQL_NUM, and the default value of MYSQL_BOTH." that is

  • I just wanted to know what exactly I should put in the second parameter of the mysql_fetch_array.

  • I posted an answer, if you have any questions, let me know.

Show 1 more comment

1 answer

3


I just wanted to know what exactly I should put in the second parameter of mysql_fetch_array.

The second argument is optional, indicating what type of array must be returned.

The possible values are: MYSQLI_ASSOC, MYSQLI_NUM, or MYSQLI_BOTH.

By default, the function mysqli_fetch_array() will take over MYSQLI_BOTH for this parameter.

  • MYSQLI_ASSOC: Returns a array associative.
  • MYSQLI_NUM: Returns a array numerically indexed.
  • MYSQLI_BOTH: Returns a array with both indexes, numerical and associative (multidimensional).
  • Vlw for the help bro.

  • 1

    @Lucascarezia Arrange =). Do not forget to change mysql_fetch_array for mysqli_fetch_array(). If possible, mark the answer by clicking below the votes.

Browser other questions tagged

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