0

hello i have a problem understanding how a function works

for example i wrote this php code

<?php
$face = $Wall->Profilepic($profile_pic_path);
$query = mysql_query("SELECT * FROM `messages` WHERE type ='A' AND uid_fk = '$uid'");
while($row=mysql_fetch_array($query))
{
echo '<a href="'.$base_url.'roves/'.$row['msg_id'].'" ><img src="'.$face.'" class="small_face" original-title="'.$row['message'].'" ></a>';
}
?>

and i named a variable $face so i can take the image from this function

public function Profilepic($uid,$base_url) 
     {

         $uid=mysql_real_escape_string($uid);
         $query = mysql_query("SELECT * FROM user_uploads WHERE uid_fk='$uid'") or die(mysql_error());
         $row=mysql_fetch_array($query);

              /*Art Uploaded Picture */
                if ($row['type']== 'A')
                {
                      if(!empty($row['image_path']))
                      {
                      $profile_pic_path=$base_url.'uploads/photos/';
                      $data= $profile_pic_path.$row['image_path'];
                      return $data;
                      }
                      else
                      {
                      $data=$base_url."wall_icons/profile-audio.jpg";
                      return $data;
                     }
                }
                elseif ($row['type']== 'T')
                {
                      if(!empty($row['image_path']))
                      {
                      $profile_pic_path=$base_url.'uploads/texts/images/';
                      $data= $profile_pic_path.$row['image_path'];
                      return $data;
                      }
                      else
                      {
                      $data=$base_url."wall_icons/text_icon.jpg";
                      return $data;
                     }
                }
                elseif ($row['type']== 'V')
                {
                      if(!empty($row['image_path']))
                      {
                      $profile_pic_path=$base_url.'uploads/videos/images/';
                      $data= $profile_pic_path.$row['image_path'];
                      return $data;
                      }
                      else
                      {
                      $data=$base_url."wall_icons/video-icon.jpg";
                      return $data;
                     }
                }
     }

what am i doing wrong?

4
Contributors
4
Replies
37
Views
3 Years
Discussion Span
Last Post by Borzoi
0

The first this is you are not using the OOP properly here. Just using in the function once. Try to have another function for waht you wrote the sql in the begining.

I am not much pro in OOP but i know that you passing wrong no of parameter in the function see in function declaration-

function Profilepic($uid,$base_url) 

and here you go while calling

$face = $Wall->Profilepic($profile_pic_path);

where is second parameters?

0

As an additional observation - $Wall should be declared somewhere as well ?

$Wall = new <ObjectName> ( Params );
0

Yes Andre the $wall is called on a included file.

So change
$face = $Wall->Profilepic($profile_pic_path);
to
$face = $Wall->Profilepic($uid,$base_url);

still the same

Edited by SimonIoa: wrong code

0

The function parameters are Profilepic($uid,$base_url)

You seem to be passing in different variables.

I would assume that $base_url is the scripting path for the hosted domain so for a Linux hosted site, it would most likely be something like /var/www/vhosts/example.com/htdocs but you'll need to confirm that with your host if it's not your own server. This would probably be declared either earlier in the file or in an include.

$uid is obviously the unique identifier for the user you're getting the profile picture for.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.