Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9191943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:48:31+00:00 2026-06-17T20:48:31+00:00

I have a table in a mySQL database where i put a value retrieved

  • 0

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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:48:33+00:00Added an answer on June 17, 2026 at 8:48 pm

    mysql_query returns a resultset, not a single result, so:

    $con="select userid from uniqueid";  
    $result=mysql_query($con) or die(mysql_error());  
    if($row=mysql_fetch_assoc($result)) { //if a row is found in resultset, then you already have this id in your table
        $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());  
    }
    

    Also you should start using mysqli functions instead of mysql, as mysql ones are deprecated

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Mysql database. I have 3 table-: table Column tier_price customer_id,sku(Unique),price,website catalog_product
I have the following task: there are a simple table from mysql database: <html>
I have put together a fairly basic local database driven website using PHP, Appache,
I have a question, how to parse datetime value from Oracle to MySQL database.
I have to return data fetched from MySQL table into a php file as
I have multiple tables in a mysql database and I am trying to put
I have table which contains double values stored in mysql database ...I need to
I have a calendar table in my MYSQL database with one field named datefield
I have a table with a field of type date within a MySQL database.
I'm trying to normalize a mysql database.... I currently have a table that contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.