WordPress.org

Ready to get started?Download WordPress

Forums

Help plz (1 post)

  1. mrhussein
    Member
    Posted 1 year ago #

    Hello..

    well i'm calling a PHP file in the root of WP containing the following:

    <?php
    global $current_user;
    get_currentuserinfo();
    $userid = $current_user->description;
    
    $serverName = "****\*****"; //serverName\instanceName
    $connectionInfo = array( "Database"=>"*******", "UID"=>"****", "PWD"=>"*******");
    $conn = sqlsrv_connect( $serverName, $connectionInfo);
    
    if( $conn ) {
         echo "Connection established.<br />";
    }else{
         echo "Connection could not be established.<br />";
         die( print_r( sqlsrv_errors(), true));
    }
    $sql = "SELECT 1, 2, 3, 4 FROM cat where id='$userid';
    $stmt = sqlsrv_query( $conn, $sql );
    
    echo "<table border='1'>
    <tr>
    <th>1</th>
    <th>2</th>
    <th>3</th>
    <th>4</th>
    </tr>";
    
    while( $row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC))
     {
      echo "<tr>";
      echo "<td>" . $row['1'] . "</td>";
      echo "<td>" . $row['2'] . "</td>";
      echo "<td>" . $row['3'] . "</td>";
      echo "<td>" . $row['4'] . "</td>";
        echo "</tr>";
      }
    
    echo "</table>";
    sqlsrv_free_stmt( $stmt);
    ?>

    but its not importing the $current_user->description;

    its showing this msg:

    Fatal error: Call to undefined function get_currentuserinfo() in C:\xampp\htdocs\as\getuser.php

    what should i put in the beging so it will import this infos from the current user login

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.