Q695 Posted April 25, 2013 Share Posted April 25, 2013 Does anyone know what mysql_num_rows has been changed to, and how to write it out for newer versions of PHP base? Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/ Share on other sites More sharing options...
Jessica Posted April 25, 2013 Share Posted April 25, 2013 Yes. It's actually in the manual. Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426603 Share on other sites More sharing options...
litebearer Posted April 25, 2013 Share Posted April 25, 2013 rough idea... $db = new mysqli($dbserver,$dbuser, $dbpass, $dbname); $query = "SELECT field FROM tablename"; $results = $db->query($query); $num_row = $results->num_rows; Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426607 Share on other sites More sharing options...
Q695 Posted April 25, 2013 Author Share Posted April 25, 2013 Yes. It's actually in the manual. The primary manual I use is: http://us.php.net/, and it didn't seem to be there. Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426618 Share on other sites More sharing options...
Jessica Posted April 25, 2013 Share Posted April 25, 2013 Really? The big bright red box telling you it's deprecated and with the option of two new extensions to use, with specific links to their pages in the manual...you don't see that big ole box? :-P Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426620 Share on other sites More sharing options...
Q695 Posted April 25, 2013 Author Share Posted April 25, 2013 (edited) Really? The big bright red box telling you it's deprecated and with the option of two new extensions to use, with specific links to their pages in the manual...you don't see that big ole box? :-P It's counting the fields in that array, not the number of arrays. Edited April 25, 2013 by Q695 Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426621 Share on other sites More sharing options...
Q695 Posted April 25, 2013 Author Share Posted April 25, 2013 I guess what I'm looking for is how to apply a counting mechanism to count $row after the mysql_fetch_assoc, but for some reason it's giving me errors. Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426629 Share on other sites More sharing options...
Jessica Posted April 25, 2013 Share Posted April 25, 2013 Count what? Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426630 Share on other sites More sharing options...
Q695 Posted April 25, 2013 Author Share Posted April 25, 2013 (edited) It's grabbing unique data for a page to load different products, and there is a handfull of almost identical products on the page they'll be linked to. I want it to be top down for new adds, not bottom up with a maximum number of options allowed to create a new product, unless hacked. Edited April 25, 2013 by Q695 Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426664 Share on other sites More sharing options...
seandisanti Posted April 25, 2013 Share Posted April 25, 2013 If you use PDO with OO approach, you can just call $statement->rowCount() Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426665 Share on other sites More sharing options...
seandisanti Posted April 25, 2013 Share Posted April 25, 2013 Really? The big bright red box telling you it's deprecated and with the option of two new extensions to use, with specific links to their pages in the manual...you don't see that big ole box? :-P Have to give them SOME credit though, it sounds like they're still putting in a bit more effort than people still asking for help to make their mysql_ calls work. Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426666 Share on other sites More sharing options...
Q695 Posted April 25, 2013 Author Share Posted April 25, 2013 (edited) This: $count=$statement->rowCount(); Gives: ( ! ) Fatal error: Call to a member function rowCount() on a non-object in _________ on line _________ When added. statement: mysql_fetch_assoc(___________); Edited April 25, 2013 by Q695 Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426668 Share on other sites More sharing options...
Jessica Posted April 25, 2013 Share Posted April 25, 2013 Either learn to read documentation, use classes and do basic debugging, or stick with your version 5.3.whatevs copypasta that is working. Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426669 Share on other sites More sharing options...
Solution seandisanti Posted April 25, 2013 Solution Share Posted April 25, 2013 http://jream.com/learning/videos/php-oop/php-oop-tutorial-22-pdo-examples 12 minute video to show you how to use PDO, it should help you out. Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426670 Share on other sites More sharing options...
Q695 Posted April 25, 2013 Author Share Posted April 25, 2013 Apache Version : 2.2.17 PHP Version : 5.3.4 Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426673 Share on other sites More sharing options...
Q695 Posted April 25, 2013 Author Share Posted April 25, 2013 finally got it for now: $count=mysql_num_rows($result); will need to update it later. Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426676 Share on other sites More sharing options...
seandisanti Posted April 26, 2013 Share Posted April 26, 2013 Resorting to the deprecated function you were trying to replace in the first line of the thread is not getting it. Just saying. Quote Link to comment https://forums.phpfreaks.com/topic/277313-mysql_num_rows-depreciationremoval/#findComment-1426688 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.