stewart715 Posted October 31, 2006 Share Posted October 31, 2006 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 thiswould i use mysql_fetch_object? Quote Link to comment https://forums.phpfreaks.com/topic/25714-pulling-simple-values-from-forms-mysqlphp/ Share on other sites More sharing options...
HuggieBear Posted October 31, 2006 Share Posted October 31, 2006 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]RegardsHuggie Quote Link to comment https://forums.phpfreaks.com/topic/25714-pulling-simple-values-from-forms-mysqlphp/#findComment-117369 Share on other sites More sharing options...
stewart715 Posted October 31, 2006 Author Share Posted October 31, 2006 Thanks for the quick reply.for some reason it's not getting the data....[code]<?phpfunction 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] Quote Link to comment https://forums.phpfreaks.com/topic/25714-pulling-simple-values-from-forms-mysqlphp/#findComment-117378 Share on other sites More sharing options...
stewart715 Posted October 31, 2006 Author Share Posted October 31, 2006 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 Quote Link to comment https://forums.phpfreaks.com/topic/25714-pulling-simple-values-from-forms-mysqlphp/#findComment-117386 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.