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

  • SEARCH
  • Home
  • 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 9255247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:40:26+00:00 2026-06-18T11:40:26+00:00

I look for examples to solve my problem but im confused. If Ii have

  • 0

I look for examples to solve my problem but im confused.
If Ii have a json array like this:

$json = '{"a":"test","b":"test2"},{"a":"test3","b":"test4"}';

//decode to get as php variable
$obj = json_decode($json);

My problem is when i try to insert the values in the database

mysql_query("INSERT INTO suspiciousactivity (ID,Notes)
VALUES ('".$obj->{'a'}."','".$obj->{'b'}."')")or die(mysql_error());

I get this error: duplicate entry for key PRIMARY

How can I insert a multiple values from my JsonArray to my database?

  • 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-18T11:40:27+00:00Added an answer on June 18, 2026 at 11:40 am

    try to use:

    $json = '{"a":"test","b":"test2"},{"a":"test3","b":"test4"}';
    
    //decode to get as php variable
    $arr = json_decode($json,true); //true to decode as a array not an object
    
    mysql_query("INSERT INTO suspiciousactivity (ID,Notes)
    VALUES ('".$arr[0]['a']."','".$arr[0]['b']."')")or die(mysql_error());
    //use it as an array.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

when I look up the syntax for .data(), it gives examples like this: $('body').data('foo',
I have a problem with internet explorer 6 and 7, please look this example
I have a problem to solve from SPOJ -like platform and I can't come
Simplified, I have to solve the following problem: You have a 2-dimensional array filled
I think I understand strong typing , but every time I look for examples
Take a look at this example: http://www.extjs.com/deploy/dev/examples/multiselect/multiselect-demo.html On it, there are components rendered against
When trying to solve this problem , I encountered some articles, etc. referring to
The problem to solve: Imagine I have a domain and corresponding web site at
I have a problem with the activiti engine, which should be simple to solve,
Higher rank types look like great fun. From the Haskell wikibook comes this example:

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.