hi i have followed a online tutorial for a friends system all is working till i attempt to install it on my website after adding the following code

<?php
if(isset($_GET['user']) && !empty($_GET['user'])){
    $user = $_GET['user'];
} else {
    $user = $_SESSION['user_id'];
}
    $my_id = $_SESSION['user_id'];
    $username = getuser($user, 'username');
?>

<?php
if($user != $my_id){
    $check_frnd_query = @mysql_query("SELECT id FROM frnds WHERE (user_one='$my_id' AND user_two='$user') OR (user_one='$user' AND user_two='$my_id')");
    if(@mysql_num_rows($check_frnd_query) == 1){
        echo "<a href='#' class='box'>Already Friends</a> | <a href='actions.php?action=unfrnd&user=$user' class='box'>Delete From Friends</a>";
    } else {
        $from_query = @mysql_query("SELECT `id` FROM `frnd_req` WHERE `from`='$user' AND `to`='$my_id'");
        $to_query = @mysql_query("SELECT `id` FROM `frnd_req` WHERE `from`='$my_id' AND `to`='$user'");
        if(@mysql_num_rows($from_query) == 1){
             echo "<a href='#' class='box'>Ignore</a> | <a href='actions.php?action=accept&user=$user' class='box'>Accept</a>";
        } else if (@mysql_num_rows($to_query) == 1){
             echo "<a href='actions.php?action=cancel&user=$user' class='box'>Cancel Request</a>";
        } else {
             echo "<a href='actions.php?action=send&user=$user' class='box'>Send Request</a>";
        }

    }
}
?>

to my profile page i get Fatal error: Call to undefined function getuser() in /home/matureco/public_html/viewprofile.php on line 45

what would the solution be any help would be greatful x

Recommended Answers

All 3 Replies

It means that you have not included the named function in the current script, if you grouped some common functions then you have to include such collection.

Again, please refrain to use MySQL API, PHP 7 has been released and this API is not anymore supported, also you MUST use prepared statements, all your scripts I've seen here on Daniweb are highly vulnerable.

As @cereal said, the old MySQL API has been deprecated. DO NOT use it! Use the MySQLi API instead. You can find details about that on the php.net web site.

i paid for a freelancer to sort the mysql out and all he did was put the @ symbols in cos i dont know where to start after several attempts to do ity myself

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.