williamZanelli Posted June 29, 2008 Share Posted June 29, 2008 The problem I;m having now is with Arrays, I'm a Java convert and a newbie to PHP. An array [returned from the database query] is empty I know this as I do print_r ($result_array) and it prints nothing However when I do use the function count($result_array) it returns 1 - Have I missed something?? ??? ??? ??? Thanks in advance Will Link to comment https://forums.phpfreaks.com/topic/112462-array-size-problem/ Share on other sites More sharing options...
thatsgreat2345 Posted June 29, 2008 Share Posted June 29, 2008 Post your code of how you are getting the data from the database as this could most likely be your problem. Link to comment https://forums.phpfreaks.com/topic/112462-array-size-problem/#findComment-577430 Share on other sites More sharing options...
DarkWater Posted June 29, 2008 Share Posted June 29, 2008 Some code would be nice. Link to comment https://forums.phpfreaks.com/topic/112462-array-size-problem/#findComment-577431 Share on other sites More sharing options...
williamZanelli Posted June 29, 2008 Author Share Posted June 29, 2008 I'm using the Smarty framework The code function is $n = $db->get_row("SELECT `link_field1` FROM " . _link . " WHERE `x_field` = '" .$incomming."' AND `_category` != ". $_cat . " AND `_status` != 'discard'"); return $n; I could do run a query like "SELECT count(*) FROM " ... But I want to avoid going into the database more than necessary... Hope this code helps Thanks for your help. Will Link to comment https://forums.phpfreaks.com/topic/112462-array-size-problem/#findComment-577435 Share on other sites More sharing options...
DarkWater Posted June 29, 2008 Share Posted June 29, 2008 Is this inside of a function? Link to comment https://forums.phpfreaks.com/topic/112462-array-size-problem/#findComment-577437 Share on other sites More sharing options...
williamZanelli Posted June 29, 2008 Author Share Posted June 29, 2008 Yes the code above is inside a fucntion that calls another fucntion [provided by the Smarty Framework] which manages database transactions. Is there any other way other than count/sizeof to check if the size of the results array from the database? Thanks Will Link to comment https://forums.phpfreaks.com/topic/112462-array-size-problem/#findComment-577567 Share on other sites More sharing options...
williamZanelli Posted June 30, 2008 Author Share Posted June 30, 2008 Anybody?? Link to comment https://forums.phpfreaks.com/topic/112462-array-size-problem/#findComment-578139 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.