How to search user login to search data in database?

Asked

Viewed 98 times

0

Good evening, everyone, I am using this command line, it worked perfectly with me typing the login of the person, but when I try to put to go based on the 'user_login' (logged in user) it does not go to page or even load when I try, I tried to use up to this here:

$current_user = wp_get_current_user();

$user_info = get_userdata($current_user->ID);

$username = $user_info->user_login;

But it didn’t work, could you help me? follows the page code:

?php

$host = "xxxx";
$db   = "xxx";
$user = "zzz";
$pass = "sddss";

$con = mysqli_pconnect($host, $user, $pass) or trigger_error(mysqli_error(),E_USER_ERROR); 

mysqli_select_db($db, $con);

$query = sprintf("SELECT valor FROM investimentos WHERE login= 'mirthrandir' ");

$dados = mysqli_query($query, $con) or die(mysqli_error());

$linha = mysqli_fetch_assoc($dados);

$total = mysqli_num_rows($dados);

?>


    
    Teste


?php
    // se o número de resultados for maior que zero, mostra os dados
    if($total > 0) {
        // inicia o loop que vai mostrar todos os dados
        do {
?>
            

?=$linha['valor']?> /

?php // finaliza o loop que vai mostrar os dados }while($linha = mysqli_fetch_assoc($dados)); // fim do if } ?>
  • I suggest that before solving this problem switch from communication library to the bank. The functions mysql_ are obsolete, use mysqli_ or PDO

  • yes yes I have already made the vlw change by tip ^^

  • Since you made the change, update the question code

  • Updated, but not sure if it is correct, I am seeking to improve

  • Thanks I didn’t realize I sent with the data.

  • What is the error message? Use this after opening the php tag to display the error messages. ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL);

  • Fatal error: Uncaught Error: Call to Undefined Function mysqi_select_db() in /home/fastinv1/public_html/teste.php:14 Stack trace: #0 {main} thrown in /home/fastinv1/public_html/teste.php on line 14 esse erro ai.

Show 2 more comments
No answers

Browser other questions tagged

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