php


php script to get data from database android


i m trying to build a JSON array from mysql. it does not get the information from mysql
<?php
$host="localhost";
$pwd="";
$user="root";
$db="mydb";
$con=mysqli_connect($host,$user,$pwd,$db) or die('Unable to connect');
if(mysqli_connect_error($con))
{
echo"failded to connect";
}
$query = mysqli_query($con,"select * from product");
if ($query)
{
while($row = mysqli_fetch_array($query))
{
$flag[] = $row;
}
print(json_encode($flag));
}
mysqli_close($con);
?>
Notice: Array to string conversion in C:\wamp\www\new\count.php on line 19
What does this error mean and how do I fix it?
Please initialize $flag something like this $flag = array()
hope it was helpful to you.
change print to print_r(json_encode($flag)) you won't get any error
You are converting your array to a json array so you have to use var_dump or print_r().

Related Links

How to validate array using foreach loop?
sending phpmailer smtp email with gmail takes long time (1.5 seconds)
Function returns array - PHP
How can I ensure that the columns in MySQL does NOT display the default “0” if user fails to enter data?
ebay trading api <ShippingDetails> nolonger available?
PHP if condition does not work anymore when inside a PHP foreach statement
PHP json_decode doesn`t work
How to read from files in UTF-16LE encoding in php?
Symfony CMF can't load homepage and another pages
Blank page in Wordpress after write a comment
How to send mail to admin email in Google Apps PHP runtime
PHP: Nested Variables Issue
Impossible to assign simple Array on Stackable
Generating pdf using phpexcel
PHP: Undefined variable in child
How to load images from https using the_field

Categories

HOME
dotnetnuke
applescript
plpgsql
braintree
gallery
liferay-7
cypher
openflow
amp
ontology
position
responsive-design
twitter-oauth
scrape
jquery-select2-4
angular4
exe
cloudsim
infrared
adobe-illustrator
batch-rename
websphere-portal
web-push
raima
miniprofiler
adapter
mdns
autodesk-model-derivative
nsmutablearray
sql-execution-plan
cloudera-manager
custom-keyboard
cordys-opentext
ms-solver-foundation
cartopy
strapi
xll
android-n
microkernel
utf
slideshow
classnotfoundexception
icepdf
moinmoin
nuclio
wysihtml5
cloudwatch
aws-kinesis-firehose
sonicmq
nusoap
sharpdx
android-mediarecorder
nslayoutconstraint
business-rules
front-camera
yargs
fuzzer
gcloud-node
maven-release-plugin
uibinder
android-async-http
accessibilityservice
cortana
arbre
opencyc
ruby-on-rails-4.1
supersocket.net
fantom
igor
mobile-country-code
lumia-imaging-sdk
accessory
jini
screwturn
tabletools
radius-protocol
accountmanager
infinite
boinc
jacob
sunstudio
chartfx
axacropdf
oscilloscope
reentrancy
proc-open
oembed
2d-vector
xmlwriter
clrprofiler
servercontrol
delphi-prism
filelock
data-dump
office-automation
uipasteboard
kext
directshow.net
qcar-sdk
solandra
ninject-interception
outlook-2007-addin
iphone-sdk-4.3
self-tracking-entities
ntruencrypt

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile