Jump to content

Help! I've tried this everyway and I can't get it


stewart715

Recommended Posts

I'm trying to return a certain template based on two data tables and I thought I did the following correctly but apparently i didn't..anyone see anything?

[code]<?php
function phptemplate_user_profile($user, $fields = array()) {
$userid = $user->uid;
$link = mysql_connect("localhost","thepdcom_popnew","password);
mysql_select_db("thepdcom_popnew",$link);
$query  = mysql_query("SELECT privacyid FROM privacymode WHERE uid = '$user->uid'");
$result = mysql_fetch_object($query);
//if profile is private
if ($result =1) {

//if user is friend
if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list')) {
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
  }
//if user is not friend
    else if ($account->uid != $user->uid && user_access('maintain buddy list')) {
return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields));
----------------
----------------
//if profile is public
} else if ($result =2) {
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
  }
//if nothing was selected
else if ($result = NULL) {
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));
  }
}

}

?>[/code]
I assume the missing quote is because you edited the password.

One problem is here:

[code]if ($result = 1)[/code]

That will assign the value 1 to $result.  Instead you should use

[code]if ($result == 1)[/code]

Also, since $result is a mysql row object, you should use:

[code]if ($result->privacyid == 1)[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.