here I have

//functions.php

<?php
session_start();

function loggedin(){
        if(@$_SESSION['username']){
            @$username = $_SESSION['username'];
            return true;
    } elseif(@$_COOKIE['username']) {
        @$username = $_COOKIE['username'];
        return true;
        }else {
            return false;
        }
}

function getuid($username) {
    $res = mysql_query("SELECT id FROM users WHERE username='$username'");
    if(mysql_num_rows($res)) {
        $row = mysql_fetch_assoc($res);
        return $row['id'];
    }
}

function getusername($uid){
    $res = mysql_query("SELECT username FROM users WHERE id='$uid'");
    if(mysql_num_rows($res)) {
       $row = mysql_fetch_assoc($res);
       return $row['username']; 
    }
}

function getsig($uid) {
    $res = mysql_query("SELECT signature FROM users_extra WHERE id='$uid'") or die(mysql_error($res));
    if(mysql_num_rows($res)) {
        $row = mysql_fetch_assoc($res);
        return $row['signature'];
    }
}


function getprofile($uid) {
    $res = mysql_query("SELECT profile FROM users_extra WHERE id='$uid'") or die(mysql_error($res));
    $row = mysql_fetch_assoc($res);
    return $row['profile'];
}
?>

When I try to call

getsig();

and

getprofile();

on the user.php it wont show up, and I cant figure it out why.
The functions seems to be allright, what can be the problem ?

//user.php

<?php
    if(@$_SESSION['username']){
            @$username = $_SESSION['username'];
    } elseif(@$_COOKIE['username']) {
        @$username = $_COOKIE['username'];
      }
      
    if($_GET['id']) {
        $uid = getuid($username);
        $username2 = getusername($_GET['id']);
        if($username2 == "") {
            echo "User does not exist.";
            exit();
        } else {
           ?>
           
           <table width="100%">
            <tr valign="top">
                <td width="10%">
                    <fieldset>
                    <legend><?php echo "Logged in as, <a href=\"index.php?act=profile&id=".$uid."\">$username2</a>"; ?></a></legend> 
                    </fieldset>
                </td>
                
                <td width="77%">
                    <fieldset>
                    <legend>Signature</legend>
                    <form action="./includes/update.php" method="post">
                    <textarea style="height: 100px;" name="ud_sig"></textarea>
                    <input type="hidden" name="ud_id" value='<? echo "$uid";?>'/>
                    </br>
                    <input type="submit" value="Add Signature" name="signature"/>
                    </form>
                    //here is problem #1
                    <?php echo getsig(getuid($username2)); ?>
                    </fieldset>
                    
                    <fieldset>
                    <legend>Profile</legend>
                    //here is problem #2
                    <?php echo getprofile(getuid($username2)); ?>
                    </fieldset>
                </td>
                
                <td width="8%">
                    <fieldset>
                    <legend>User info</legend>
                    <p>Posts: 0</p>                  
                    </fieldset>
                </td>
            </tr>
           </table>
           
           <?php
        }
    } else {
        echo "Specifica un id.";
        exit();
    }

?>
Member Avatar for rajarajan2017

Nothing to worry aboutthat, Just include your functions.php in user.php

<?php
include('functions.php'); 
?>

check your functions in a separte file
say test.php

<?php
include "functions.php";
echo getsig('someuid')."<br>";
echo getprofile('someuid');
?>

see whether it is giving propers output or not.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.