MasterACE14 Posted December 4, 2007 Share Posted December 4, 2007 Evening, I use my own Custom functions for querying my database but for some reason my function is only working for SELECTing from my `cf_users` table and not my `cf_users2` table. here's my selecting function: <?php // Select fields from the user table function player_table($select){ $where = $_SESSION['playerid']; $sql = "SELECT `" . what_table($select) . "`.`" . $select . "` FROM `cf_users` INNER JOIN `cf_users2` ON (`cf_users2`.`id` = `cf_users`.`id`) LIMIT 1"; $rs = mysql_query($sql) or die('Query:<br />' . $sql . '<br /><br />Error:<br />' . mysql_error()); while($row = mysql_fetch_assoc($rs)){ if(isset($row[$select])){return $row[$select];} } }; /* and what_table(); function used for working out to select from cf_users or cf_users2 */ // Check if the column in the database is in 1 table or another function what_table($column) { $fields = mysql_list_fields("database", "cf_users"); $columns = mysql_num_fields($fields); for ($i = 0; $i < $columns; $i++) { $field_array[] = mysql_field_name($fields, $i); } if(!in_array($column, $field_array)) { $table = "cf_users2"; } elseif(in_array($column, $field_array)) { $table = "cf_users"; } return $table; }; here's my user details for my account in `cf_users2`, showing column name then value: level_supplysize - 2 | amount_supplysize - 200 | price_supplysize - 500 and this is what is being echo'd onto the page, use the player_table(); function: level_supplysize - 1 | amount_supplysize - 100 | price_supplysize - 250 I have no idea why this is happenning, but I really need to get this fixed ASAP, any and all help is greatly appreciated Regards ACE Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted December 4, 2007 Share Posted December 4, 2007 try echoing out hte $sql in player_table function to see the sql maybe it will help 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.