Problems with PHP 5.2 [closed]

0

I've made a Admin page for a site and when I uploaded it on the server I discovered that the PHP version is 5.2 and there's no way I can upgrade the server always present me error in the mysql_fetch_array() function, I would like to know if it has an equivalent function for php 5.2 and if the PDO could solve my problem?

Here's the code I've made:

$selecao = mysql_query("SELECT * FROM nome_table WHERE nivel = 'Cliente' 
                        ORDER BY nome_contato"); 

while ($selecao_dados = mysql_fetch_array($selecao)) { 

    echo $id = base64_encode($selecao_dados['id_user']); 

} 

The error:

    
asked by anonymous 06.02.2015 / 12:03

1 answer

1

Try changing your code to something like:

$querySQL = 'SELECT * FROM tabela_usuario WHERE id = 1234';
$query = mysql_query($querySQL);

if (!($row = mysql_fetch_array($query, MYSQL_ASSOC)))
{
    echo 'Usuário não encontrado!';
} else {
    while ($row = mysql_fetch_array($query, MYSQL_ASSOC))
        var_dump($row);
    echo 'Usuário encontrado!';
}

I tested it here and it worked perfectly (PHP VERSION 5.6.3), needing clear adaptations, for your need ... in the case of SQL;

    
06.02.2015 / 12:29