• i want to get the esc_attr(um_user(‘display_name’)); to my new php for find the user data from sql this is my code
    temp_test.php

    <?php
    $servername = "localhost";
    $username = "root";
    $password = "admin";
    $dbname = "root";
    
    $display_name = um_user('display_name');
    //$divs = $html->find('a[title]');  
    // Create connection
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Check connection
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    } 
    
    $sql = "SELECT avgtemp FROM $display_name ORDER BY num DESC LIMIT 1";
    $result = $conn->query($sql);
    
    if ($result->num_rows > 0) {
        // output data of each row
        if($row = $result->fetch_assoc()) {
             echo $row["avgtemp"];
        }
    }
    $conn->close();
    ?>
    • This topic was modified 6 years, 11 months ago by kang0905.
    • This topic was modified 6 years, 11 months ago by kang0905.
    • This topic was modified 6 years, 11 months ago by kang0905.
Viewing 1 replies (of 1 total)
  • @kang0905 please don’t display usernames and passwords to access your database in a public forum like this. Whilst your setup is localhost, it’s not best practice for obvious reasons.

    In addition, you’d be better placed using the default functions of WordPress to establish a DB connection rather then reinvent the wheel.

Viewing 1 replies (of 1 total)
  • The topic ‘how can php get the user name’ is closed to new replies.