rockinaway Posted May 22, 2011 Share Posted May 22, 2011 I have some OOP code im working on and I have some interactions with the database. However, mysql_fetch_array fails to be working. Have I missed something? class core { var $array_batsmen = ''; var $array_bowlers = ''; // Query to get batsmen function get_batsmen() { return $this->array_batsmen = mysql_query('SELECT id, name, ability, strength FROM wtw_players WHERE team_id = 1 ORDER BY id ASC'); } // Query to get bowlers function get_bowlers() { $this->array_bowlers = mysql_query('SELECT id, name, ability, strength FROM wtw_players WHERE team_id = 2'); } // Generate array of batsmen to be used function generateBatsmen() { while ($array = mysql_fetch_array($this->array_batsmen)) { echo $array['name']; } } } The functions are called later normally, i've only included the necessary parts. Basically I have the var $array_batsmen which stores the mysql_query. This is then later used with a mysql_fetch_array to return names from the earlier query. But nothing happens! It doesn't return anything (don't worry, I have a return later on). The loop just doesn't seem to work :/ Quote Link to comment https://forums.phpfreaks.com/topic/237105-mysql_fetch_array-killing-me-a-little/ Share on other sites More sharing options...
rockinaway Posted May 22, 2011 Author Share Posted May 22, 2011 Oh I should also mention, I am using a mysql_fetch_array elsewhere in my code and it works perfectly fine with the $array_batsmen query. I don't understand why it fails to work here :s Quote Link to comment https://forums.phpfreaks.com/topic/237105-mysql_fetch_array-killing-me-a-little/#findComment-1218667 Share on other sites More sharing options...
PFMaBiSmAd Posted May 22, 2011 Share Posted May 22, 2011 Define: mysql_fetch_array fails to be working? What is your code doing? An error? No values? Quote Link to comment https://forums.phpfreaks.com/topic/237105-mysql_fetch_array-killing-me-a-little/#findComment-1218669 Share on other sites More sharing options...
rockinaway Posted May 22, 2011 Author Share Posted May 22, 2011 Fixed it! Forgot to put a mysql_data_seek() in! Thanks anyway! Quote Link to comment https://forums.phpfreaks.com/topic/237105-mysql_fetch_array-killing-me-a-little/#findComment-1218672 Share on other sites More sharing options...
PFMaBiSmAd Posted May 22, 2011 Share Posted May 22, 2011 ^^^ Just as well, because without your actual code that was producing the symptom, no one could have helped you with the problem anyway. Quote Link to comment https://forums.phpfreaks.com/topic/237105-mysql_fetch_array-killing-me-a-little/#findComment-1218673 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.