I have a table in a mySQL database where i put a value retrieved from an android application using php.
Now the value is a UniqueID,so i am keeping a count of it,so that i can know how many times my application is accessed.
When a new UniqueID arrives it is added to the database with count=1 and when an existing UniqueID is retieved,its count is simply incremented.
I tried my php script multiple times but with no luck. I am attaching my php script for reference.
<?php
ini_set('default_charset', 'utf-8');
header('Content-Type: text/html; charset=UTF-8');
$n=$_POST['UniqueID'];
$count=1;
$Today=date("F j, Y, g:i a");
mysql_connect("localhost","root","");
mysql_select_db("farm-o-pedia");
$con="select userid from uniqueid";
$result=mysql_query($con) or die(mysql_error());
if($result=$n)
{
$upd="update uniqueid set count=count+1 where userid=$n";
$result=mysql_query($upd) or die(mysql_error());
}
else {
$que="insert into uniqueid (userid,count,date) values($n,\"$count\",\"$Today\")";
$sql=mysql_query($que) or die(mysql_error());
}
mysql_close();
?>
Any help would be appreciated.Thanks!
mysql_query returns a resultset, not a single result, so:
Also you should start using mysqli functions instead of mysql, as mysql ones are deprecated