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 upload to files to amazon EC2
Getting the top scores, but remove duplicate users (SQL)
Explode a string after 5 spaces and 2 new lines in a string in PHP
How to create a button that links to different URL using if-else statement
How to display category's items?
Distinguish tr in dynamic table form for serializing jQuery
phpMyAdmin doesn't show new databases
decode base64 and pass to zip file
Passing POST data from ionic framework to CodeIgniter Rest API
Mail function can be misused
PHP - Is it possible to upload a zip file to the database after the zip is created in php?
Path to mpdf/jpgraph library in PHPExcel example on Windows
Convert row from database into image
How To Use Google Sheets API v4 To Create New Sheet or Tab in Spreadsheet with PHP
PHP $_POST arrays with multiple rows
Displaying nothing when I am trying to scrape data using simple html dom parser

Categories

HOME
webview
plesk
class
tomcat
cucumber
command-prompt
hdfs
drag-and-drop
fedora
tweepy
kurento
port
nsstring
amazon-emr
csrf
rangy
createjs
ex
dhcp
sql-injection
c#-7.0
codefluent
spring-shell
node-webkit
conda
amazon-sns
intel
backendless
animated-gif
react-dnd
jpa-2.1
oracleforms
spring-annotations
splunk-query
quick-nimble
rust-cargo
xcrun
actframework
payeezy
bluemixtools
ftp-server
nanogallery
installanywhere
forms-authentication
identify
text-decorations
tidal-scheduler
system-on-chip
expandablelistview
.net-micro-framework
subforms
nslayoutconstraint
apache-modules
zynq
android-4.2-jelly-bean
exists
vaadin4spring
gulp-uglify
wikimedia-commons
diawi
opencyc
lowercase
enaml
compositetype
cache-manifest
componentart
prism-4
text-align
image-rotation
dmake
multivariate-testing
nachos
forio-contour
wso2bam
armv6
django-settings
smips
vlab
infinite
mousemotionlistener
codahale-metrics
tnt4j
.net-remoting
xs
delphi-xe4
web-frameworks
semantic-merge
exponent
upshot
simile
principles
getimagesize
index.dat
autobench
activex-exe

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