wordpress $current user working in opera, empty in chrome!!!

Discussion in 'WordPress' started by developerno1, Dec 18, 2013.

  1. #1
    i have a php snippet to get account expiry of the user from my wp db..
    now i use a few wp functions to get it running($current_User) get_currentuserinfo().
    this works nicely in opera but not in chrome where the result is empty..
    I am logged in both(as thats the most obviuos doubt which comes..) here is the code..
    <?php
    $con=mysqli_connect("host","uname","admin","\wrdp1");
    $result = mysqli_query($con,"SELECT * FROM wp_usermeta");
    
    require( $_SERVER['DOCUMENT_ROOT'].'/wp-load.php' );
    require( $_SERVER['DOCUMENT_ROOT'].'/wp-content/plugins/s2member/s2member.php' );
    global $current_user;
    get_currentuserinfo();
    echo "Hello " , $current_user->display_name , "! \n";
    echo '<html>', "<br><br>",'</html>';
    echo "Your account will expire on :";
    $name=$current_user->user_login;
    $result = mysqli_query($con,"SELECT ID FROM wp_users where user_login='".$name."';");
    if (mysqli_num_rows($result) == 0) {
        echo "No record";
        exit;
    }
    while ($row = mysqli_fetch_assoc($result)) {
    $uid=$row["ID"];
    }
    $result2 = mysqli_query($con,"SELECT meta_value FROM wp_usermeta where user_id='".$uid."' AND meta_key = 'wp_s2member_auto_eot_time';");
    while ($row2 = mysqli_fetch_assoc($result2)) {
    echo '<html>', "<br>",'</html>';
        echo date("j F Y",$row2["meta_value"]);
    }
    echo '<html>', "<br><br>",'</html>';
    echo "Need an extension?", '<html><br><a href="http://www.gettefl.com/course-extension/">Click here.</a></html>';
    mysqli_close($con);
    ?>
    
    PHP:

     
    developerno1, Dec 18, 2013 IP
  2. Curtis Mangione

    Curtis Mangione Member

    Messages:
    14
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    25
    #2
    The code you have pasted above is as PHP and happens before any data is send to the user so browser is irrelevant.

    I believe your issue lies here:

    echo '<html>', "<br>",'</html>';
        echo date("j F Y",$row2["meta_value"]);
    }
    echo '<html>', "<br><br>",'</html>';
    echo "Need an extension?", '<html><br><a href="http://www.gettefl.com/course-extension/">Click here.</a></html>';
    PHP:
    You are opening the <html> tag, closing it, and then outputting content to the page.

    All your content should go in a <body> tag nested within the <html> tags

    ex:
    <html>
    <body>CONTENT HERE</body>
    </html>
     
    Curtis Mangione, Jan 22, 2014 IP