stewart715 Posted October 31, 2006 Share Posted October 31, 2006 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 theright 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 errorprint 'Privacy mode error';} }?>[/code] Quote Link to comment Share on other sites More sharing options...
trq Posted October 31, 2006 Share Posted October 31, 2006 Replace this....[code=php:0]$sql = mysql_query("SELECT privacyid FROM privacymode WHERE (uid = '$user->uid')");[/code]with[code=php:0]$sql = "SELECT privacyid FROM privacymode WHERE uid = '{$user->uid}'";[/code] Quote Link to comment Share on other sites More sharing options...
stewart715 Posted October 31, 2006 Author Share Posted October 31, 2006 THANK YOU SO MUCH!!!!!! That was so annoying I tried everything. Thanks again. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.