Jump to content

[resolved] I can't figure it out. Simple MySQL Error


stewart715

Recommended Posts

This is so important to me, I've been working on it for days and can't figure it out! Any help is MUCH appreciated. Thank you all for all your help.

You probably have seen posts like this here but I absolutely cannot figure it out. Everything looks perfect to me. It is a simple INT(11) type column. The explaination for what is trying to get done is in the script below.

When I try to view a profile, I get this error, with a different resource Id# for each user.

[code]
Unable to run Resource id #182: You have an error in your SQL syntax;
check the manual that corresponds to your MySQL server version for the
right syntax to use near 'Resource id #182' at line 1
[/code][code]
<?php

//Privacy mode integrated with user_profile.tpl.php and private_profile.tpl.php
//
//A user selects either 'Private Mode' (Value of 1) or 'Public Mode' (Value of 2) from
//an HTML form. When submitted, their $user->uid (User ID Number) is inserted into column
//'uid' in table 'privacymode.' The selected value (either 1 or 2) is also inserted into
//that table in column 'privacyid,' in the same row as their $user->uid of course.
//
//The script selects the 'privacyid' where the $user->uid of the owner of the profile in which the user
//is trying to view and if the 'privacyid' is 2, it will show the profile (since it is public),
//if it is 1, it will detect if the user who is trying to view is a friend, if they are a friend it will
//display the profile. If the user isn't a friend, it will show rejection page. If the user has
//not selected private nor public mode, by default, it will show rejection page.
function phptemplate_user_profile($user, $fields = array()) {
$link = mysql_connect("localhost","thepdcom_popnew","password");
mysql_select_db("thepdcom_popnew",$link);
$sql = mysql_query("SELECT privacyid FROM privacymode WHERE (uid = '$user->uid')");
$result = mysql_query($sql) or die ("Unable to run $sql: " . mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);

if ($row['privacyid'] == 2){  //public profile
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));

} else  if ($row['privacyid'] == 1){  //private profile

if (@in_array($user->uid, array_keys(buddylist_get_buddies($account->uid))) && user_access('maintain buddy list')) { //user is friend
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));

} else {  //user is not friend
return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields));

}

} else  if ($row['privacyid'] == NULL){ //profile user has not selected a privacy mode
return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields));

} else { //some error
print 'Privacy mode error';
}
  }
?>[/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.