php


Get number of returned rows mysqli php


I have been trying to solve this for some time. I'm tiring to echo the number of returned rows from the mysql query,
$linkTow = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
$getVotesSQL = "SELECT null FROM votes WHERE `idgame` = ?";
$getVotesStmt = $linkTow->prepare($getVotesSQL);
$getVotesStmt->bind_param("s", $idGame);
$getVotesStmt->execute();
echo $getVotesStmt->num_rows;
$getVotesStmt->close();
$linkTow->close();
I always get 0.
If you really prefer using $linkTow->prepare then this is the proper way to do it:
$getVotesSQL = "SELECT null FROM votes WHERE `idgame` = ?";
$getVotesStmt = $linkTow->prepare($getVotesSQL);
$getVotesStmt->bind_param("s", $idGame);
$getVotesStmt->execute();
$getVotesStmt->store_result(); // <- IMPORTANT
echo $getVotesStmt->num_rows;
$getVotesStmt->close();
$linkTow->close();
What you are doing before is for $linkTow->query
MANUAL
http://php.net/manual/en/mysqli-stmt.num-rows.php

Related Links

How to solve Command line: '/opt/lampp/bin/httpd -E /opt/lampp/logs/error_log -D SSL -D PHP' error?
Autocomplete list of Name with Image
Not able to insert the data from url to database in php
Show percentage time progress bar form submission PHP ajax
Install dependent project from git repositroy
How to increment value in MySQL with PHP mysqli
Change the view of the datatable poulated table in cakephp
How to link data between tables in same mySQL database?
Remove individual theme option fields from Wordpress theme
Laravel: PDO Exception, cannot find driver even though the driver is installed and tested [duplicate]
How to arrange the_content() in Wordpress post page?
Remove tags from product page in Woocommerce
import sql file in php
simple form using bootstrap and php script completely not working
query false but performs query
How to stop loop redirection in ZF2 Module

Categories

HOME
qt
visual-studio
verification
vagrant
openxml
redmine
plaid
tfs2015
haxe
cdi
timber
port
siesta
orc
squirrel-sql
django-rq
asp.net-core-1.0
phonegap-build
mixpanel
salt-cloud
codefluent
azure-machine-learning
exchange-server-2010
router
tracing
react-bootstrap-table
bitbake
substance
envoy
tightvnc
vcenter
creation
pdfminer
landscape
bluemixtools
love2d
macports
extbase
right-click
jacoco-maven-plugin
get-event-store
hdiv
opal-framework
1wire
kitura
ol3-google-maps
sigsegv
skip-lists
htmlspecialchars
email-forwarding
predicates
business-rules
google-shopping-api
seccomp
maximize
wepay
grinder
phpquery
dsa
wso2ml
espresso
blockquote
embeddedwebserver
webproject
azure-xplat-cli
python-curses
iodocs
cout
iplimage
multivariate-testing
nodeload
ivalueconverter
windows-taskbar
django-sites
strdup
eclim
grails-2.3
rautomation
iirf
insertonsubmit
flv
chefspec
proc-open
user-forums
struts2-json-plugin
border-box
kaazing
nsfont
mkannotation
datacontracts
server-variables
qt-mobility
fork-join
qcar-sdk
webresponse
aggregator
uninstaller
.net-services
dm
projectpier
downcasting
index.dat

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App