Jump to content

Recommended Posts

i have a form where you can choose either 1 or 2 and when submitted it is put into a database table along with that persons uid..the column is INT(10)

i justt need script that pulls the data where the uid is that persons uid and if the value is 1, show this..if the vaule is 2, show this

would i use mysql_fetch_object?
I'd use mysql_fetch_array()

[code]
<?php
$sql = "SELECT column FROM table WHERE uid = '$uid'";
$result = mysql_query($sql) or die ("Unable to run $sql: " . mysql_error());
$row = mysql_fetch_array($result, MYSQL_ASSOC);

if ($row['column'] == 1){
  // do something here
}
else {
  // do something here
}
?>
[/code]

Regards
Huggie
Thanks for the quick reply.

for some reason it's not getting the data....

[code]<?php
function phptemplate_user_profile($user, $fields = array()) {
$link = mysql_connect("localhost","thepdcom_popnew","pass");
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){
return _phptemplate_callback('user_profile', array('user' => $user, 'fields' => $fields));

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

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));

}

else if ($account->uid != $user->uid && user_access('maintain buddy list')) {
return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields));

}

} else  if ($row['privacyid'] == NULL){
return _phptemplate_callback('private_profile', array('user' => $user, 'fields' => $fields));

}
  }
?>


[/code]
I'm getting this error with the above code..

Unable to run Resource id #187: 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 #187' at line 1
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.