teng84 Posted August 15, 2007 Share Posted August 15, 2007 why do i get a single value of array when doing print_r the page contain more than 10,000 record i dont understand as you can see everything is fine can you tell me the possible solution or error $qry = "SELECT * FROM categories "; $result=mysql_query($qry); $total = mysql_fetch_array($result); print_r($total); Quote Link to comment https://forums.phpfreaks.com/topic/64964-solved-help-crazy-output/ Share on other sites More sharing options...
jcombs_31 Posted August 15, 2007 Share Posted August 15, 2007 use an associative array. I don't understand why you want want to return your results they way you are doing it. I tend to always use a while loop while($row = mysql_fetch_assoc($result)) { echo $row['field in db you want']; or do something else with it } Quote Link to comment https://forums.phpfreaks.com/topic/64964-solved-help-crazy-output/#findComment-324174 Share on other sites More sharing options...
teng84 Posted August 15, 2007 Author Share Posted August 15, 2007 even if i do that i get single result. like what ive said i have morethan 10, 000 record but when i do the fetch thing it returns only one record???? we have a test server which i test this using php myadmin and everything works fine . can you tell me the possible error im doing Quote Link to comment https://forums.phpfreaks.com/topic/64964-solved-help-crazy-output/#findComment-324180 Share on other sites More sharing options...
cooldude832 Posted August 15, 2007 Share Posted August 15, 2007 try mysql_num_rows($result) that might give you some clue Quote Link to comment https://forums.phpfreaks.com/topic/64964-solved-help-crazy-output/#findComment-324183 Share on other sites More sharing options...
teng84 Posted August 15, 2007 Author Share Posted August 15, 2007 i tried everything when i do this SELECT count(id) FROM categories it returns correct result but the error is that when i will have morethan one in my array tru msql fetching it will only return single result Quote Link to comment https://forums.phpfreaks.com/topic/64964-solved-help-crazy-output/#findComment-324188 Share on other sites More sharing options...
cooldude832 Posted August 15, 2007 Share Posted August 15, 2007 just humor me and run this version <?php $q = "SELECT * FROM categories"; $result = mysql_query($q) or die(mysql_error()); $total = mysql_fetch_assoc($result); $rows = mysql_num_rows($result); echo "Number of Rows: ".$rows."<br/><br/><br/>"; print_r($total); ?> and then view its source Quote Link to comment https://forums.phpfreaks.com/topic/64964-solved-help-crazy-output/#findComment-324196 Share on other sites More sharing options...
teng84 Posted August 15, 2007 Author Share Posted August 15, 2007 thank for the help i think its a server error any ways thanks for the help i will never forget this crazy error i got this makes my day > > Quote Link to comment https://forums.phpfreaks.com/topic/64964-solved-help-crazy-output/#findComment-324202 Share on other sites More sharing options...
cooldude832 Posted August 15, 2007 Share Posted August 15, 2007 just remember its $_SESSION not $_SESSSION Quote Link to comment https://forums.phpfreaks.com/topic/64964-solved-help-crazy-output/#findComment-324205 Share on other sites More sharing options...
Barand Posted August 15, 2007 Share Posted August 15, 2007 $qry = "SELECT * FROM categories "; $result=mysql_query($qry); $total = mysql_fetch_array($result); print_r($total); You do the query, you get the first record, you print_r its contents. Why would you expect more than one record with that code? Quote Link to comment https://forums.phpfreaks.com/topic/64964-solved-help-crazy-output/#findComment-324210 Share on other sites More sharing options...
teng84 Posted August 15, 2007 Author Share Posted August 15, 2007 barand i think when you print_r your fetch thing it will return the whole content i see my error and the error is that i have the same variable name so when the loop run it gets overwriten its really hard to find the error because this is big site and it have thousands of lines any way thanks Quote Link to comment https://forums.phpfreaks.com/topic/64964-solved-help-crazy-output/#findComment-324215 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.